• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.multimodalInput.keyEvent (Key Event)
2
3The **keyEvent** module provides key events reported by an input device.
4
5> **NOTE**<br>
6> 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.
7
8## Modules to Import
9
10```js
11import {Action, Key, KeyEvent} from '@ohos.multimodalInput.keyEvent';
12```
13
14## Action
15
16Defines a key action.
17
18**System capability**: SystemCapability.MultimodalInput.Input.Core
19
20| Name  | Value | Description    |
21| ------ | ------- | -------- |
22| CANCEL | 0    |  Cancellation of a key action.|
23| DOWN   | 1    | Pressing of a key.|
24| UP     | 2    | Release of a key.|
25
26## Key
27
28Defines a key.
29
30**System capability**: SystemCapability.MultimodalInput.Input.Core
31
32| Name       | Type| Readable| Writable| Description          |
33| ----------- | -------- | ---- | ---- | -------------- |
34| code        | KeyCode  | Yes  | No  | Keycode.        |
35| pressedTime | number   | Yes  | No  | Time when the key is pressed.|
36| deviceId    | number   | Yes  | No  | ID of the device to which the key belongs.  |
37
38## KeyEvent
39
40Defines a key event.
41
42**System capability**: SystemCapability.MultimodalInput.Input.Core
43
44| Name       | Type| Readable| Writable| Description                          |
45| ----------- | -------- | ---- | ---- | ------------------------------ |
46| action      | Action   | Yes  | No  | Key action.                      |
47| key         | Key      | Yes  | No  | Key for which the event is reported.            |
48| unicodeChar | number   | Yes  | No  | Unicode character corresponding to the key.         |
49| keys        | Key[]    | Yes  | No  | List of pressed keys.    |
50| ctrlKey     | boolean  | Yes  | No  | Whether ctrlKey is being pressed.   |
51| altKey      | boolean  | Yes  | No  | Whether altKey is being pressed.    |
52| shiftKey    | boolean  | Yes  | No  | Whether shiftKey is being pressed.  |
53| logoKey     | boolean  | Yes  | No  | Whether logoKey is being pressed.   |
54| fnKey       | boolean  | Yes  | No  | Whether fnKey is being pressed.     |
55| capsLock    | boolean  | Yes  | No  | Whether capsLock is active.  |
56| numLock     | boolean  | Yes  | No  | Whether numLock is active.   |
57| scrollLock  | boolean  | Yes  | No  | Whether scrollLock is active.|
58