1e41f4b71Sopenharmony_ci# @ohos.multimodalInput.inputEventClient (Input Event Injection) (System API) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **inputEventClient** module implements the input event injection capability. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> - 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. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> - The APIs provided by this module are system APIs. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## Modules to Import 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci```js 14e41f4b71Sopenharmony_ciimport { inputEventClient } from '@kit.InputKit'; 15e41f4b71Sopenharmony_ci``` 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci## inputEventClient.injectEvent 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ciinjectEvent({KeyEvent: KeyEvent}): void 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ciInjects keys (including single keys and combination keys). 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ciPermission required: ohos.permission.INJECT_INPUT_EVENT 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**Parameters** 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 30e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | --------- | 31e41f4b71Sopenharmony_ci| KeyEvent | [KeyEvent](#keyevent) | Yes | Key event to inject.| 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci**Error codes** 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci| ID | Error Message | 38e41f4b71Sopenharmony_ci| ---- | --------------------- | 39e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci**Example** 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci```js 44e41f4b71Sopenharmony_citry { 45e41f4b71Sopenharmony_ci let backKeyDown: inputEventClient.KeyEvent = { 46e41f4b71Sopenharmony_ci isPressed: true, 47e41f4b71Sopenharmony_ci keyCode: 2, 48e41f4b71Sopenharmony_ci keyDownDuration: 0, 49e41f4b71Sopenharmony_ci isIntercepted: false 50e41f4b71Sopenharmony_ci } 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci class EventDown { 53e41f4b71Sopenharmony_ci KeyEvent: inputEventClient.KeyEvent | null = null 54e41f4b71Sopenharmony_ci } 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci let eventDown: EventDown = { KeyEvent: backKeyDown } 57e41f4b71Sopenharmony_ci inputEventClient.injectEvent(eventDown); 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci let backKeyUp: inputEventClient.KeyEvent = { 60e41f4b71Sopenharmony_ci isPressed: false, 61e41f4b71Sopenharmony_ci keyCode: 2, 62e41f4b71Sopenharmony_ci keyDownDuration: 0, 63e41f4b71Sopenharmony_ci isIntercepted: false 64e41f4b71Sopenharmony_ci }; 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ci class EventUp { 67e41f4b71Sopenharmony_ci KeyEvent: inputEventClient.KeyEvent | null = null 68e41f4b71Sopenharmony_ci } 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci let eventUp: EventUp = { KeyEvent: backKeyUp } 71e41f4b71Sopenharmony_ci inputEventClient.injectEvent(eventUp); 72e41f4b71Sopenharmony_ci} catch (error) { 73e41f4b71Sopenharmony_ci console.log(`Failed to inject KeyEvent, error: ${JSON.stringify(error, [`code`, `message`])}`); 74e41f4b71Sopenharmony_ci} 75e41f4b71Sopenharmony_ci``` 76e41f4b71Sopenharmony_ci## inputEventClient.injectKeyEvent<sup>11+</sup> 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_ciinjectKeyEvent(keyEvent: KeyEventData): void 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ciInjects key events (for both single keys and combination keys). 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ciPermission required: ohos.permission.INJECT_INPUT_EVENT 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci**Parameters** 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 89e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | --------- | 90e41f4b71Sopenharmony_ci| keyEvent | [KeyEventData](#keyeventdata11) | Yes | Key event to inject.| 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci**Error codes** 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci| ID | Error Message | 97e41f4b71Sopenharmony_ci| ---- | --------------------- | 98e41f4b71Sopenharmony_ci| 202 | SystemAPI permission error. | 99e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | 100e41f4b71Sopenharmony_ci 101e41f4b71Sopenharmony_ci**Example** 102e41f4b71Sopenharmony_ci 103e41f4b71Sopenharmony_ci```js 104e41f4b71Sopenharmony_citry { 105e41f4b71Sopenharmony_ci let backKeyDown: inputEventClient.KeyEvent = { 106e41f4b71Sopenharmony_ci isPressed: true, 107e41f4b71Sopenharmony_ci keyCode: 2, 108e41f4b71Sopenharmony_ci keyDownDuration: 0, 109e41f4b71Sopenharmony_ci isIntercepted: false 110e41f4b71Sopenharmony_ci } 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci class EventDown { 113e41f4b71Sopenharmony_ci KeyEvent: inputEventClient.KeyEvent | null = null 114e41f4b71Sopenharmony_ci } 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci let eventDown: EventDown = { KeyEvent: backKeyDown } 117e41f4b71Sopenharmony_ci inputEventClient.injectKeyEvent(eventDown); 118e41f4b71Sopenharmony_ci 119e41f4b71Sopenharmony_ci let backKeyUp: inputEventClient.KeyEvent = { 120e41f4b71Sopenharmony_ci isPressed: false, 121e41f4b71Sopenharmony_ci keyCode: 2, 122e41f4b71Sopenharmony_ci keyDownDuration: 0, 123e41f4b71Sopenharmony_ci isIntercepted: false 124e41f4b71Sopenharmony_ci }; 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_ci class EventUp { 127e41f4b71Sopenharmony_ci KeyEvent: inputEventClient.KeyEvent | null = null 128e41f4b71Sopenharmony_ci } 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci let eventUp: EventUp = { KeyEvent: backKeyUp } 131e41f4b71Sopenharmony_ci inputEventClient.injectKeyEvent(eventUp); 132e41f4b71Sopenharmony_ci} catch (error) { 133e41f4b71Sopenharmony_ci console.log(`Failed to inject KeyEvent, error: ${JSON.stringify(error, [`code`, `message`])}`); 134e41f4b71Sopenharmony_ci} 135e41f4b71Sopenharmony_ci``` 136e41f4b71Sopenharmony_ci## inputEventClient.injectMouseEvent<sup>11+</sup> 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ciinjectMouseEvent(mouseEvent: MouseEventData): void; 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ciInjects a mouse/touchpad event. 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ciPermission required: ohos.permission.INJECT_INPUT_EVENT 145e41f4b71Sopenharmony_ci 146e41f4b71Sopenharmony_ci**Parameters** 147e41f4b71Sopenharmony_ci 148e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 149e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | --------- | 150e41f4b71Sopenharmony_ci| mouseEvent | [MouseEventData](#mouseeventdata11) | Yes | Mouse/touchpad event to inject.| 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci**Error codes** 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ci| ID | Error Message | 157e41f4b71Sopenharmony_ci| ---- | --------------------- | 158e41f4b71Sopenharmony_ci| 202 | SystemAPI permission error. | 159e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_ci**Example** 162e41f4b71Sopenharmony_ci 163e41f4b71Sopenharmony_ci```js 164e41f4b71Sopenharmony_ciimport { MouseEvent } from '@kit.InputKit'; 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_citry { 167e41f4b71Sopenharmony_ci let mouseButtonUpData: mouseEvent.MouseEvent = { 168e41f4b71Sopenharmony_ci id: 0, 169e41f4b71Sopenharmony_ci deviceId: 1, 170e41f4b71Sopenharmony_ci actionTime: 2, 171e41f4b71Sopenharmony_ci screenId: 1, 172e41f4b71Sopenharmony_ci windowId: 0, 173e41f4b71Sopenharmony_ci action: 3, 174e41f4b71Sopenharmony_ci screenX: 100, 175e41f4b71Sopenharmony_ci screenY: 200, 176e41f4b71Sopenharmony_ci windowX: 100, 177e41f4b71Sopenharmony_ci windowY: 200, 178e41f4b71Sopenharmony_ci rawDeltaX: 200, 179e41f4b71Sopenharmony_ci rawDeltaY: 200, 180e41f4b71Sopenharmony_ci button: 2, 181e41f4b71Sopenharmony_ci pressedButtons: [2], 182e41f4b71Sopenharmony_ci axes: [], 183e41f4b71Sopenharmony_ci pressedKeys: [0], 184e41f4b71Sopenharmony_ci ctrlKey: false, 185e41f4b71Sopenharmony_ci altKey: false, 186e41f4b71Sopenharmony_ci shiftKey: false, 187e41f4b71Sopenharmony_ci logoKey: false, 188e41f4b71Sopenharmony_ci fnKey: false, 189e41f4b71Sopenharmony_ci capsLock: false, 190e41f4b71Sopenharmony_ci numLock: false, 191e41f4b71Sopenharmony_ci scrollLock: false, 192e41f4b71Sopenharmony_ci toolType: 1, 193e41f4b71Sopenharmony_ci } 194e41f4b71Sopenharmony_ci let mouseButtonUp: inputEventClient.MouseEventData = { 195e41f4b71Sopenharmony_ci mouseEvent: mouseButtonUpData 196e41f4b71Sopenharmony_ci } 197e41f4b71Sopenharmony_ci inputEventClient.injectMouseEvent(mouseButtonUp); 198e41f4b71Sopenharmony_ci 199e41f4b71Sopenharmony_ci let mouseButtonDownData: mouseEvent.MouseEvent = { 200e41f4b71Sopenharmony_ci id: 0, 201e41f4b71Sopenharmony_ci deviceId: 1, 202e41f4b71Sopenharmony_ci actionTime: 2, 203e41f4b71Sopenharmony_ci screenId: 1, 204e41f4b71Sopenharmony_ci windowId: 0, 205e41f4b71Sopenharmony_ci action: 2, 206e41f4b71Sopenharmony_ci screenX: 100, 207e41f4b71Sopenharmony_ci screenY: 200, 208e41f4b71Sopenharmony_ci windowX: 100, 209e41f4b71Sopenharmony_ci windowY: 200, 210e41f4b71Sopenharmony_ci rawDeltaX: 200, 211e41f4b71Sopenharmony_ci rawDeltaY: 200, 212e41f4b71Sopenharmony_ci button: 2, 213e41f4b71Sopenharmony_ci pressedButtons: [2], 214e41f4b71Sopenharmony_ci axes: [], 215e41f4b71Sopenharmony_ci pressedKeys: [0], 216e41f4b71Sopenharmony_ci ctrlKey: false, 217e41f4b71Sopenharmony_ci altKey: false, 218e41f4b71Sopenharmony_ci shiftKey: false, 219e41f4b71Sopenharmony_ci logoKey: false, 220e41f4b71Sopenharmony_ci fnKey: false, 221e41f4b71Sopenharmony_ci capsLock: false, 222e41f4b71Sopenharmony_ci numLock: false, 223e41f4b71Sopenharmony_ci scrollLock: false, 224e41f4b71Sopenharmony_ci toolType: 1, 225e41f4b71Sopenharmony_ci } 226e41f4b71Sopenharmony_ci let mouseButtonDown: inputEventClient.MouseEventData = { 227e41f4b71Sopenharmony_ci mouseEvent: mouseButtonDownData 228e41f4b71Sopenharmony_ci }; 229e41f4b71Sopenharmony_ci inputEventClient.injectMouseEvent(mouseButtonDown); 230e41f4b71Sopenharmony_ci} 231e41f4b71Sopenharmony_ci 232e41f4b71Sopenharmony_cicatch (error) { 233e41f4b71Sopenharmony_ci console.log(`Failed to inject MouseEvent, error: ${JSON.stringify(error, [`code`, `message`])}`); 234e41f4b71Sopenharmony_ci} 235e41f4b71Sopenharmony_ci 236e41f4b71Sopenharmony_ci``` 237e41f4b71Sopenharmony_ci 238e41f4b71Sopenharmony_ci## inputEventClient.injectTouchEvent<sup>11+</sup> 239e41f4b71Sopenharmony_ci 240e41f4b71Sopenharmony_ciinjectTouchEvent(touchEvent: TouchEventData): void 241e41f4b71Sopenharmony_ci 242e41f4b71Sopenharmony_ciInjects a touchscreen event. 243e41f4b71Sopenharmony_ci 244e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator 245e41f4b71Sopenharmony_ci 246e41f4b71Sopenharmony_ciPermission required: ohos.permission.INJECT_INPUT_EVENT 247e41f4b71Sopenharmony_ci 248e41f4b71Sopenharmony_ci**Parameters** 249e41f4b71Sopenharmony_ci 250e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 251e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | --------- | 252e41f4b71Sopenharmony_ci| touchEvent | [TouchEventData](#toucheventdata11) | Yes | Touchscreen event to inject.| 253e41f4b71Sopenharmony_ci 254e41f4b71Sopenharmony_ci**Error codes** 255e41f4b71Sopenharmony_ci 256e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 257e41f4b71Sopenharmony_ci 258e41f4b71Sopenharmony_ci| ID | Error Message | 259e41f4b71Sopenharmony_ci| ---- | --------------------- | 260e41f4b71Sopenharmony_ci| 202 | SystemAPI permission error. | 261e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | 262e41f4b71Sopenharmony_ci 263e41f4b71Sopenharmony_ci**Example** 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_ci```js 266e41f4b71Sopenharmony_ciimport { TouchEvent } from '@kit.InputKit'; 267e41f4b71Sopenharmony_ci 268e41f4b71Sopenharmony_citry { 269e41f4b71Sopenharmony_ci let touchEvent: touchEvent.Touch = { 270e41f4b71Sopenharmony_ci id: 1, 271e41f4b71Sopenharmony_ci pressedTime: 1, 272e41f4b71Sopenharmony_ci screenX: 0, 273e41f4b71Sopenharmony_ci screenY: 0, 274e41f4b71Sopenharmony_ci windowX: 0, 275e41f4b71Sopenharmony_ci windowY: 0, 276e41f4b71Sopenharmony_ci pressure: 0, 277e41f4b71Sopenharmony_ci width: 0, 278e41f4b71Sopenharmony_ci height: 0, 279e41f4b71Sopenharmony_ci tiltX: 0, 280e41f4b71Sopenharmony_ci tiltY: 0, 281e41f4b71Sopenharmony_ci toolX: 0, 282e41f4b71Sopenharmony_ci toolY: 0, 283e41f4b71Sopenharmony_ci toolWidth: 0, 284e41f4b71Sopenharmony_ci toolHeight: 0, 285e41f4b71Sopenharmony_ci rawX: 0, 286e41f4b71Sopenharmony_ci rawY: 0, 287e41f4b71Sopenharmony_ci toolType: 0, 288e41f4b71Sopenharmony_ci } 289e41f4b71Sopenharmony_ci 290e41f4b71Sopenharmony_ci let touchEventUpData: touchEvent.TouchEvent = { 291e41f4b71Sopenharmony_ci action: 1, 292e41f4b71Sopenharmony_ci sourceType: 0, 293e41f4b71Sopenharmony_ci touch: touchEvent, 294e41f4b71Sopenharmony_ci touches: [], 295e41f4b71Sopenharmony_ci id: 0, 296e41f4b71Sopenharmony_ci deviceId: 0, 297e41f4b71Sopenharmony_ci actionTime: 0, 298e41f4b71Sopenharmony_ci screenId: 0, 299e41f4b71Sopenharmony_ci windowId: 0 300e41f4b71Sopenharmony_ci } 301e41f4b71Sopenharmony_ci ; 302e41f4b71Sopenharmony_ci let touchEventUp: inputEventClient.TouchEventData = { 303e41f4b71Sopenharmony_ci touchEvent: touchEventUpData 304e41f4b71Sopenharmony_ci } 305e41f4b71Sopenharmony_ci inputEventClient.injectTouchEvent(touchEventUp); 306e41f4b71Sopenharmony_ci 307e41f4b71Sopenharmony_ci let touchEventDownData: touchEvent.TouchEvent = { 308e41f4b71Sopenharmony_ci action: 1, 309e41f4b71Sopenharmony_ci sourceType: 0, 310e41f4b71Sopenharmony_ci touch: touchEvent, 311e41f4b71Sopenharmony_ci touches: [], 312e41f4b71Sopenharmony_ci id: 0, 313e41f4b71Sopenharmony_ci deviceId: 0, 314e41f4b71Sopenharmony_ci actionTime: 0, 315e41f4b71Sopenharmony_ci screenId: 0, 316e41f4b71Sopenharmony_ci windowId: 0 317e41f4b71Sopenharmony_ci } 318e41f4b71Sopenharmony_ci ; 319e41f4b71Sopenharmony_ci let touchEventDown: inputEventClient.TouchEventData = { 320e41f4b71Sopenharmony_ci touchEvent: touchEventDownData 321e41f4b71Sopenharmony_ci } 322e41f4b71Sopenharmony_ci inputEventClient.injectTouchEvent(touchEventDown); 323e41f4b71Sopenharmony_ci} catch (error) { 324e41f4b71Sopenharmony_ci console.log(`Failed to inject touchEvent, error: ${JSON.stringify(error, [`code`, `message`])}`); 325e41f4b71Sopenharmony_ci} 326e41f4b71Sopenharmony_ci``` 327e41f4b71Sopenharmony_ci 328e41f4b71Sopenharmony_ci## inputEventClient.permitInjection<sup>12+</sup> 329e41f4b71Sopenharmony_ci 330e41f4b71Sopenharmony_cipermitInjection(result: boolean): void 331e41f4b71Sopenharmony_ci 332e41f4b71Sopenharmony_ciSpecifies whether to authorize event injection. 333e41f4b71Sopenharmony_ci 334e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator 335e41f4b71Sopenharmony_ci 336e41f4b71Sopenharmony_ciPermission required: ohos.permission.INJECT_INPUT_EVENT 337e41f4b71Sopenharmony_ci 338e41f4b71Sopenharmony_ci**Parameters** 339e41f4b71Sopenharmony_ci 340e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 341e41f4b71Sopenharmony_ci| -------- | ------ | ---- | --------- | 342e41f4b71Sopenharmony_ci| result | boolean | Yes | Authorization result. The value **true** indicates that event injection is allowed, and the value **false** indicates the opposite.| 343e41f4b71Sopenharmony_ci 344e41f4b71Sopenharmony_ci**Error codes** 345e41f4b71Sopenharmony_ci 346e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 347e41f4b71Sopenharmony_ci 348e41f4b71Sopenharmony_ci| ID | Error Message | 349e41f4b71Sopenharmony_ci| ---- | --------------------- | 350e41f4b71Sopenharmony_ci| 202 | SystemAPI permission error. | 351e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | 352e41f4b71Sopenharmony_ci 353e41f4b71Sopenharmony_ci 354e41f4b71Sopenharmony_ci```ts 355e41f4b71Sopenharmony_ciimport { inputEventClient } from '@kit.InputKit'; 356e41f4b71Sopenharmony_ci 357e41f4b71Sopenharmony_citry { 358e41f4b71Sopenharmony_ci let result = true; 359e41f4b71Sopenharmony_ci inputEventClient.permitInjection(result); 360e41f4b71Sopenharmony_ci}catch(error){ 361e41f4b71Sopenharmony_ci console.error("failed:" + JSON.stringify(error)); 362e41f4b71Sopenharmony_ci} 363e41f4b71Sopenharmony_ci``` 364e41f4b71Sopenharmony_ci 365e41f4b71Sopenharmony_ci## KeyEvent 366e41f4b71Sopenharmony_ci 367e41f4b71Sopenharmony_ciDefines the key event to inject. 368e41f4b71Sopenharmony_ci 369e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator 370e41f4b71Sopenharmony_ci 371e41f4b71Sopenharmony_ci| Name | Type | Readable | Writable | Description | 372e41f4b71Sopenharmony_ci| --------- | ------ | ---- | ---- | ------- | 373e41f4b71Sopenharmony_ci| isPressed | boolean | Yes | No| Whether the key is pressed.<br>The value **true** indicates that the key is pressed, and the value **false** indicates the opposite. | 374e41f4b71Sopenharmony_ci| keyCode | number | Yes | No| Keycode value. Currently, only the **KEYCODE_BACK** key is supported.| 375e41f4b71Sopenharmony_ci| keyDownDuration | number | Yes | No| Duration for pressing a key, in μs. | 376e41f4b71Sopenharmony_ci| isIntercepted | boolean | Yes | No| Whether the key event can be intercepted.<br>The value **true** indicates that the key event can be intercepted, and the value **false** indicates the opposite.| 377e41f4b71Sopenharmony_ci 378e41f4b71Sopenharmony_ci## KeyEventData<sup>11+</sup> 379e41f4b71Sopenharmony_ci 380e41f4b71Sopenharmony_ciDefines the key event to inject. 381e41f4b71Sopenharmony_ci 382e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator 383e41f4b71Sopenharmony_ci 384e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 385e41f4b71Sopenharmony_ci| --------- | ------ | ---- | ------- | 386e41f4b71Sopenharmony_ci| keyEvent | [KeyEvent](#keyevent) | Yes | Key event to inject. | 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_ci## MouseEventData<sup>11+</sup> 389e41f4b71Sopenharmony_ci 390e41f4b71Sopenharmony_ciDefines the mouse event data. 391e41f4b71Sopenharmony_ci 392e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator 393e41f4b71Sopenharmony_ci 394e41f4b71Sopenharmony_ci| Name | Type | Readable | Writable | Description | 395e41f4b71Sopenharmony_ci| --------- | ------ | ---- | ---- | ------- | 396e41f4b71Sopenharmony_ci| mouseEvent | [MouseEvent](js-apis-mouseevent.md#mouseevent) | Yes | No| Mouse event data. | 397e41f4b71Sopenharmony_ci 398e41f4b71Sopenharmony_ci## TouchEventData<sup>11+</sup> 399e41f4b71Sopenharmony_ci 400e41f4b71Sopenharmony_ciDefines the touchscreen event data. 401e41f4b71Sopenharmony_ci 402e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator 403e41f4b71Sopenharmony_ci 404e41f4b71Sopenharmony_ci| Name | Type | Readable | Writable | Description | 405e41f4b71Sopenharmony_ci| --------- | ------ | ---- | ---- | ------- | 406e41f4b71Sopenharmony_ci| touchEvent | [TouchEvent](js-apis-touchevent.md#touchevent) | Yes | No| Touchscreen event data | 407