1# Input Event Client 2 3The input event client provides the key injection capability. 4 5> **NOTE** 6> 7> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> 9> - The APIs of this module are system APIs and cannot be called by third-party applications. 10 11 12## Modules to Import 13 14 15```js 16import inputEventClient from '@ohos.multimodalInput.inputEventClient'; 17``` 18 19 20## inputEventClient.injectEvent 21 22injectEvent({KeyEvent: KeyEvent}): void 23 24Injects a key. 25 26This is a system API. 27 28**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator 29 30**Parameters** 31 32| Name| Type| Mandatory| Description| 33| -------- | -------- | -------- | -------- | 34| KeyEvent | [KeyEvent](#keyevent) | Yes| Information about the key to inject.| 35 36**Example** 37 38```js 39let keyEvent = { 40 isPressed: true, 41 keyCode: 2, 42 keyDownDuration: 0, 43 isIntercepted: false 44} 45let res = inputEventClient.injectEvent({KeyEvent: keyEvent}); 46``` 47 48 49## KeyEvent 50 51Defines the information about the key to inject. 52 53This is a system API. 54 55**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator 56 57| Name| Type| Mandatory| Description| 58| -------- | -------- | -------- | -------- | 59| isPressed | boolean | Yes| Whether the key is pressed.| 60| keyCode | number | Yes | Key code. | 61| keyDownDuration | number | Yes | Duration within which the key is pressed. | 62| isIntercepted | boolean | Yes | Whether the key can be intercepted.| 63