<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/KeyPress",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI8KeyPressV"
  },
  "title" : "KeyPress"
}
-->

# KeyPress

```
struct KeyPress
```

## Topics

### Getting the keypress

[`let key: KeyEquivalent`](/documentation/SwiftUI/KeyPress/key)

The key equivalent value for the pressed key.

[`let characters: String`](/documentation/SwiftUI/KeyPress/characters)

The characters generated by the pressed key as if no modifier
key applies.

[`let modifiers: EventModifiers`](/documentation/SwiftUI/KeyPress/modifiers)

The set of modifier keys the user held in addition to the
pressed key.

### Getting the phase of the keypress

[`let phase: KeyPress.Phases`](/documentation/SwiftUI/KeyPress/phase)

The phase of the key-press event (`.down`, `.repeat`, or `.up`).

[`struct Phases`](/documentation/SwiftUI/KeyPress/Phases)

Options for matching different phases of a key-press event.

### Getting the result

[`enum Result`](/documentation/SwiftUI/KeyPress/Result)

A result value returned from a key-press action that indicates whether
the action consumed the event.

## Relationships

### Conforms To

[`Escapable`](/documentation/Swift/Escapable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Copyable`](/documentation/Swift/Copyable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)