<!--
{
  "availability" : [
    "Xcode: 16.3.0 -",
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "XCUIAutomation",
  "identifier" : "/documentation/XCUIAutomation/XCUIKeyboardKey",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "XCUIAutomation"
    ],
    "preciseIdentifier" : "c:@T@XCUIKeyboardKey"
  },
  "title" : "XCUIKeyboardKey"
}
-->

# XCUIKeyboardKey

Constants to represent keys that have no typewritten equivalent.

```
struct XCUIKeyboardKey
```

## Discussion

These constants represent the set of modifier, navigation, function, and other keys on most keyboards.

## Topics

### Modifier keys

[`XCUIKeyboardKeyCommand`](/documentation/XCUIAutomation/XCUIKeyboardKey/command)

A constant that represents the Command key.

[`XCUIKeyboardKeyControl`](/documentation/XCUIAutomation/XCUIKeyboardKey/control)

A constant that represents the Control key.

[`XCUIKeyboardKeyOption`](/documentation/XCUIAutomation/XCUIKeyboardKey/option)

A constant that represents the Option key.

[`XCUIKeyboardKeyShift`](/documentation/XCUIAutomation/XCUIKeyboardKey/shift)

A constant that represents the Shift key.

[`XCUIKeyboardKeyRightCommand`](/documentation/XCUIAutomation/XCUIKeyboardKey/rightCommand)

A constant that represents the right Command key.

[`XCUIKeyboardKeyRightControl`](/documentation/XCUIAutomation/XCUIKeyboardKey/rightControl)

A constant that represents the right Control key.

[`XCUIKeyboardKeyRightOption`](/documentation/XCUIAutomation/XCUIKeyboardKey/rightOption)

A constant that represents the right Option key.

[`XCUIKeyboardKeyRightShift`](/documentation/XCUIAutomation/XCUIKeyboardKey/rightShift)

A constant that represents the right Shift key.

### Navigation keys

[`XCUIKeyboardKeyUpArrow`](/documentation/XCUIAutomation/XCUIKeyboardKey/upArrow)

A constant that represents the Up Arrow key.

[`XCUIKeyboardKeyDownArrow`](/documentation/XCUIAutomation/XCUIKeyboardKey/downArrow)

A constant that represents the Down Arrow key.

[`XCUIKeyboardKeyLeftArrow`](/documentation/XCUIAutomation/XCUIKeyboardKey/leftArrow)

A constant that represents the Left Arrow key.

[`XCUIKeyboardKeyRightArrow`](/documentation/XCUIAutomation/XCUIKeyboardKey/rightArrow)

A constant that represents the Right Arrow key.

[`XCUIKeyboardKeyHome`](/documentation/XCUIAutomation/XCUIKeyboardKey/home)

A constant that represents the Home key.

[`XCUIKeyboardKeyEnd`](/documentation/XCUIAutomation/XCUIKeyboardKey/end)

A constant that represents the End key.

[`XCUIKeyboardKeyPageUp`](/documentation/XCUIAutomation/XCUIKeyboardKey/pageUp)

A constant that represents the Page Up key.

[`XCUIKeyboardKeyPageDown`](/documentation/XCUIAutomation/XCUIKeyboardKey/pageDown)

A constant that represents the Page Down key.

[`XCUIKeyboardKeyHelp`](/documentation/XCUIAutomation/XCUIKeyboardKey/help)

A constant that represents the Help key.

### Function keys

[`XCUIKeyboardKeySecondaryFn`](/documentation/XCUIAutomation/XCUIKeyboardKey/secondaryFn)

A constant that represents the Function key.

[`XCUIKeyboardKeyF1`](/documentation/XCUIAutomation/XCUIKeyboardKey/F1)

A constant that represents the F1 key.

[`XCUIKeyboardKeyF2`](/documentation/XCUIAutomation/XCUIKeyboardKey/F2)

A constant that represents the F2 key.

[`XCUIKeyboardKeyF3`](/documentation/XCUIAutomation/XCUIKeyboardKey/F3)

A constant that represents the F3 key.

[`XCUIKeyboardKeyF4`](/documentation/XCUIAutomation/XCUIKeyboardKey/F4)

A constant that represents the F4 key.

[`XCUIKeyboardKeyF5`](/documentation/XCUIAutomation/XCUIKeyboardKey/F5)

A constant that represents the F5 key.

[`XCUIKeyboardKeyF6`](/documentation/XCUIAutomation/XCUIKeyboardKey/F6)

A constant that represents the F6 key.

[`XCUIKeyboardKeyF7`](/documentation/XCUIAutomation/XCUIKeyboardKey/F7)

A constant that represents the F7 key.

[`XCUIKeyboardKeyF8`](/documentation/XCUIAutomation/XCUIKeyboardKey/F8)

A constant that represents the F8 key.

[`XCUIKeyboardKeyF9`](/documentation/XCUIAutomation/XCUIKeyboardKey/F9)

A constant that represents the F9 key.

[`XCUIKeyboardKeyF10`](/documentation/XCUIAutomation/XCUIKeyboardKey/F10)

A constant that represents the F10 key.

[`XCUIKeyboardKeyF11`](/documentation/XCUIAutomation/XCUIKeyboardKey/F11)

A constant that represents the F11 key.

[`XCUIKeyboardKeyF12`](/documentation/XCUIAutomation/XCUIKeyboardKey/F12)

A constant that represents the F12 key.

[`XCUIKeyboardKeyF13`](/documentation/XCUIAutomation/XCUIKeyboardKey/F13)

A constant that represents the F13 key.

[`XCUIKeyboardKeyF14`](/documentation/XCUIAutomation/XCUIKeyboardKey/F14)

A constant that represents the F14 key.

[`XCUIKeyboardKeyF15`](/documentation/XCUIAutomation/XCUIKeyboardKey/F15)

A constant that represents the F15 key.

[`XCUIKeyboardKeyF16`](/documentation/XCUIAutomation/XCUIKeyboardKey/F16)

A constant that represents the F16 key.

[`XCUIKeyboardKeyF17`](/documentation/XCUIAutomation/XCUIKeyboardKey/F17)

A constant that represents the F17 key.

[`XCUIKeyboardKeyF18`](/documentation/XCUIAutomation/XCUIKeyboardKey/F18)

A constant that represents the F18 key.

[`XCUIKeyboardKeyF19`](/documentation/XCUIAutomation/XCUIKeyboardKey/F19)

A constant that represents the F19 key.

### Text-editing keys

[`XCUIKeyboardKeyCapsLock`](/documentation/XCUIAutomation/XCUIKeyboardKey/capsLock)

A constant that represents the Caps Lock key.

[`XCUIKeyboardKeyDelete`](/documentation/XCUIAutomation/XCUIKeyboardKey/delete)

A constant that represents the Delete key.

[`XCUIKeyboardKeyForwardDelete`](/documentation/XCUIAutomation/XCUIKeyboardKey/forwardDelete)

A constant that represents the Forward Delete key.

[`XCUIKeyboardKeySpace`](/documentation/XCUIAutomation/XCUIKeyboardKey/space)

A constant that represents the Space bar.

[`XCUIKeyboardKeyTab`](/documentation/XCUIAutomation/XCUIKeyboardKey/tab)

A constant that represents the Tab key.

### Other keys

[`XCUIKeyboardKeyClear`](/documentation/XCUIAutomation/XCUIKeyboardKey/clear)

A constant that represents the Clear key.

[`XCUIKeyboardKeyEnter`](/documentation/XCUIAutomation/XCUIKeyboardKey/enter)

A constant that represents the Enter key.

[`XCUIKeyboardKeyEscape`](/documentation/XCUIAutomation/XCUIKeyboardKey/escape)

A constant that represents the Escape key.

[`XCUIKeyboardKeyReturn`](/documentation/XCUIAutomation/XCUIKeyboardKey/return)

A constant that represents the Return key.

### Initializers

[`init(_:)`](/documentation/XCUIAutomation/XCUIKeyboardKey/init(_:))

Initializes a constant with a string that represents a keyboard key.

[`init(rawValue:)`](/documentation/XCUIAutomation/XCUIKeyboardKey/init(rawValue:))

Initializes a constant with a string that represents a keyboard key.

## Relationships

### Conforms To

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

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

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

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

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

---

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)