<!--
{
  "availability" : [
    "iOS: 13.4.0 -",
    "iPadOS: 13.4.0 -",
    "macCatalyst: 13.4.0 -",
    "tvOS: 13.4.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIKey",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIKey"
  },
  "title" : "UIKey"
}
-->

# UIKey

An object that provides information about the state of a keyboard key.

```
@MainActor class UIKey
```

## Overview

[`UIKey`](/documentation/UIKit/UIKey) provides relevant information about the current state of a key on a keyboard as a user presses and releases the key. To learn more, see [Handling key presses made on a physical keyboard](/documentation/UIKit/handling-key-presses-made-on-a-physical-keyboard).

## Topics

### Determining key type

[`keyCode`](/documentation/UIKit/UIKey/keyCode)

The HID usage code of the key.

[`modifierFlags`](/documentation/UIKit/UIKey/modifierFlags)

The modifier keys pressed and held while the user presses the key.

### Getting key characters

[`characters`](/documentation/UIKit/UIKey/characters)

A string that represents the text value of the key combined with any active modifier keys.

[`charactersIgnoringModifiers`](/documentation/UIKit/UIKey/charactersIgnoringModifiers)

A string that represents the text value of the key without modifier keys.

## Relationships

### Conforms To

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

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

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

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

[`NSCoding`](/documentation/Foundation/NSCoding)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

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

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

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)