1# @ohos.multimodalInput.keyEvent (Key Event)
2
3The **keyEvent** module provides key events reported by a device. It is inherited from [InputEvent](js-apis-inputevent.md).
4
5>  **NOTE**
6>
7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9## Modules to Import
10
11```js
12import { Action, Key, KeyEvent } from '@kit.InputKit';
13```
14
15## Action
16
17Key event type.
18
19**Atomic service API**: This API can be used in atomic services since API version 12.
20
21**System capability**: SystemCapability.MultimodalInput.Input.Core
22
23| Name  | Value | Description    |
24| ------ | ------- | -------- |
25| CANCEL | 0    | Cancellation of a key action.|
26| DOWN   | 1    | Pressing of a key.|
27| UP     | 2    | Release of a key.|
28
29## Key
30
31Defines a key.
32
33**Atomic service API**: This API can be used in atomic services since API version 12.
34
35**System capability**: SystemCapability.MultimodalInput.Input.Core
36
37| Name       | Type| Readable| Writable| Description          |
38| ----------- | -------- | ---- | ---- | -------------- |
39| code        | [KeyCode](js-apis-keycode.md#keycode)  | Yes  | No  | Keycode.        |
40| pressedTime | number   | Yes  | No  | Duration for pressing a key, in μs.|
41| deviceId    | number   | Yes  | No  | ID of the device to which the key belongs.  |
42
43## KeyEvent
44
45Key event.
46
47**Atomic service API**: This API can be used in atomic services since API version 12.
48
49**System capability**: SystemCapability.MultimodalInput.Input.Core
50
51| Name       | Type| Readable| Writable| Description                          |
52| ----------- | -------- | ---- | ---- | ------------------------------ |
53| action      | [Action](#action)   | Yes  | No  | Key action.                      |
54| key         | [Key](#key)      | Yes  | No  | Key for which the event is reported.            |
55| unicodeChar | number   | Yes  | No  | Unicode character corresponding to the key.         |
56| keys        | [Key](#key) []    | Yes  | No  | List of pressed keys.    |
57| ctrlKey     | boolean  | Yes  | No  | Whether ctrlKey is being pressed.<br>The value **true** indicates that the key is pressed, and the value **false** indicates the opposite.|
58| altKey      | boolean  | Yes  | No  | Whether altKey is being pressed.<br>The value **true** indicates that the key is pressed, and the value **false** indicates the opposite.    |
59| shiftKey    | boolean  | Yes  | No  | Whether shiftKey is being pressed.<br>The value **true** indicates that the key is pressed, and the value **false** indicates the opposite.  |
60| logoKey     | boolean  | Yes  | No  | Whether logoKey is being pressed.<br>The value **true** indicates that the key is pressed, and the value **false** indicates the opposite.   |
61| fnKey       | boolean  | Yes  | No  | Whether fnKey is being pressed.<br>The value **true** indicates that the key is pressed, and the value **false** indicates the opposite.     |
62| capsLock    | boolean  | Yes  | No  | Whether capsLock is active.<br>The value **true** indicates that capsLock is active, and the value **false** indicates the opposite.  |
63| numLock     | boolean  | Yes  | No  | Whether numLock is active.<br>The value **true** indicates that capsLock is active, and the value **false** indicates the opposite.   |
64| scrollLock  | boolean  | Yes  | No  | Whether scrollLock is active.<br>The value **true** indicates that capsLock is active, and the value **false** indicates the opposite.|
65