diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 5d92003cfc6c07adf9d7812c8015809dd99b2a35..e49c1914712daa6733ef54b4b74af109ab769704 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -191,6 +191,7 @@ - [@ohos.multimodalInput.inputDevice](js-apis-inputdevice.md) - [@ohos.multimodalInput.inputEventClient](js-apis-inputeventclient.md) - [@ohos.multimodalInput.inputMonitor](js-apis-inputmonitor.md) + - [@ohos.multimodalInput.inputEvent](js-apis-inputevent.md) - [@ohos.power](js-apis-power.md) - [@ohos.runningLock](js-apis-runninglock.md) - [@ohos.sensor](js-apis-sensor.md) diff --git a/en/application-dev/reference/apis/js-apis-inputconsumer.md b/en/application-dev/reference/apis/js-apis-inputconsumer.md index 3e9a9af045b92543f5e9221b5ffa199c4bf9b054..8a458433505279ac0bd72b1d418972b409bd59f9 100644 --- a/en/application-dev/reference/apis/js-apis-inputconsumer.md +++ b/en/application-dev/reference/apis/js-apis-inputconsumer.md @@ -1,9 +1,10 @@ # Combination Key -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
+> > - 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. -> +> > - The APIs of this module are system APIs and cannot be called by third-party applications. @@ -17,66 +18,71 @@ import inputConsumer from '@ohos.multimodalInput.inputConsumer'; ## inputConsumer.on -on(type: "key", keyOption: KeyOption, callback: Callback<KeyOption>): void +on(type: "key", keyOptions: KeyOptions, callback: Callback): void -Enables listening for combination key events. When a combination key event that meets the specified conditions occurs, **keyOption** will be passed as an input parameter to **callback**. +Enables listening for combination key events. When a combination key event that meets the specified conditions occurs, **keyOptions** will be passed as an input parameter to **callback**. **System capability**: SystemCapability.MultimodalInput.Input.InputConsumer - **Parameters** - | Name | Type | Mandatory | Description | +**Parameters** + +| Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| type | string | Yes | Type of the key input event to listen for. Only **key** is supported. | -| keyOption | [KeyOption](#keyoption) | Yes | Key option, which specifies the condition for combination key input. | -| callback | Callback<KeyOption> | Yes | Callback function. When a key input event that meets the specified options occurs, **keyOption** will be passed as an input parameter to **callback**. | +| type | string | Yes| Type of the key input event to listen for. Only **key** is supported.| +| keyOptions | [keyOptions](#keyOptions) | Yes| Key option, which specifies the condition for combination key input.| +| callback | KeyOptions | Yes| Callback used to return the result.
When a key input event that meets the specified options occurs, **keyOptions** will be passed as an input parameter to **callback**.| - **Example** +**Example** ``` -let keyOption = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0} -let callback = function(keyOption) { - console.info("preKeys: " + keyOption.preKeys, "finalKey: " + keyOption.finalKey, - "isFinalKeyDown: " + keyOption.isFinalKeyDown, "finalKeyDownDuration: " + keyOption.finalKeyDownDuration) +let keyOptions = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0} +let callback = function(keyOptions) { + console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey, + "isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration) } -inputConsumer.on('key', keyOption, callback); +inputConsumer.on('key', keyOptions, callback); ``` ## inputConsumer.off -off(type: "key", keyOption: KeyOption, callback: Callback<KeyOption>): void +off(type: "key", keyOptions: KeyOptions, callback?: Callback): void Stops listening for combination key events. **System capability**: SystemCapability.MultimodalInput.Input.InputConsumer - **Parameters** - | Name | Type | Mandatory | Description | +**Parameters** + +| Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| type | string | Yes | Type of the key input event to listen for. Only **key** is supported. | -| keyOption | [KeyOption](#keyoption) | Yes | Key option passed to the key input event when listening starts. | -| callback | Callback<KeyOption> | Yes | Callback function passed to the key input event with the key option when listening starts. | +| type | string | Yes| Type of the key input event to listen for. Only **key** is supported.| +| keyOptions | [keyOptions](#keyOptions) | Yes| Key options passed to the key input event when listening starts.| +| callback | Callback | Yes| Callback function passed to the key input event with **keyOptions** when listening starts.| - **Example** +**Example** ``` -let keyOption = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0} -let callback = function(keyOption) { - console.info("preKeys: " + keyOption.preKeys, "finalKey: " + keyOption.finalKey, - "isFinalKeyDown: " + keyOption.isFinalKeyDown, "finalKeyDownDuration: " + keyOption.finalKeyDownDuration) +let keyOptions = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0} +let callback = function(keyOptions) { + console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey, + "isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration) } -inputConsumer.off('key', keyOption, callback); +inputConsumer.off('key', keyOptions, callback); ``` -## KeyOption +## keyOptions Defines the key options that are met when a combination key input event occurs. - **System capability**: SystemCapability.MultimodalInput.Input.InputConsumer - | Name | Type | Mandatory | Description | +**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer + +**Parameters** + +| Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| preKeys | Array | Yes | Array of precedent keys. This parameter can be left empty. There is no requirement on the sequence of precedent keys. | -| finalKey | Number | Yes | Final key in the combination key. This parameter cannot be left blank. | -| isFinalKeyDown | boolean | Yes | Indicates whether the final key is pressed or released. By default, the final key is pressed. | -| finalKeyDownDuration | Number | Yes | Duration for pressing the final key. By default, there is no requirement on the duration. | +| preKeys | Array | Yes| Array of precedent keys. This parameter can be left empty. There is no requirement on the sequence of precedent keys.| +| finalKey | Number | Yes| Final key in the combination key. This parameter cannot be left blank.| +| isFinalKeyDown | boolean | Yes| Whether the final key is pressed or released. By default, the final key is pressed.| +| finalKeyDownDuration | Number | Yes| Duration for pressing the final key. By default, there is no requirement on the duration.| diff --git a/en/application-dev/reference/apis/js-apis-inputevent.md b/en/application-dev/reference/apis/js-apis-inputevent.md new file mode 100644 index 0000000000000000000000000000000000000000..5718f96c2c75a8950af27d7de8e9ad40866d4198 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-inputevent.md @@ -0,0 +1,22 @@ +# Input Event + +> **NOTE**
+> 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. + +## Modules to Import + +```js +import InputEvent from '@ohos.multimodalInput.inputEvent'; +``` + +**System capability**: SystemCapability.MultimodalInput.Input.Core + +**Parameters** + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| id | number | Yes| No| Unique event ID generated by the server.| +| deviceId | number | Yes| No| ID of the device that reports the input event.| +| actionTime | number | Yes| No| Time when the event is reported.| +| screenId | number | Yes| No| ID of the target screen.| +| windowId | number | Yes| No| ID of the target window.| diff --git a/en/application-dev/reference/apis/js-apis-inputeventclient.md b/en/application-dev/reference/apis/js-apis-inputeventclient.md index ed3942bb5920474b06ae829521a77bf483d1cac0..be8c4ad17b0963d9761194eb009580ef37347e31 100644 --- a/en/application-dev/reference/apis/js-apis-inputeventclient.md +++ b/en/application-dev/reference/apis/js-apis-inputeventclient.md @@ -1,17 +1,17 @@ -# Input Event Client +# Key Injection -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> -> - 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. +> 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. > -> - The APIs of this module are system APIs and cannot be called by third-party applications. +> The APIs of this module are system APIs and cannot be called by third-party applications. ## Modules to Import -``` +```js import inputEventClient from '@ohos.multimodalInput.inputEventClient'; ``` @@ -20,38 +20,40 @@ import inputEventClient from '@ohos.multimodalInput.inputEventClient'; injectEvent({KeyEvent: KeyEvent}): void -Injects a key. +Injects a key event. **System capability**: SystemCapability.MultimodalInput.Input.InputSimulator **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| KeyEvent | [KeyEvent](#keyevent) | Yes| Information about the key to inject.| +| Name | Type | Mandatory | Description | +| -------- | --------------------- | ---- | --------- | +| KeyEvent | [KeyEvent](#keyevent) | Yes | Information about the key event to inject.| **Example** -``` +```js let keyEvent = { isPressed: true, keyCode: 2, keyDownDuration: 0, isIntercepted: false } -res = inputEventClient.injectEvent({KeyEvent: keyEvent}); +let res = inputEventClient.injectEvent({KeyEvent: keyEvent}); ``` ## KeyEvent -Defines the information about the key to inject. +Defines the information about the key event to inject. **System capability**: SystemCapability.MultimodalInput.Input.InputSimulator -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| isPressed | boolean | Yes| Whether the key is pressed.| -| keyCode | Number | Yes| Key code.| -| keyDownDuration | boolean | Yes| Duration for which the key is pressed.| -| isIntercepted | Number | Yes| Whether the key can be intercepted.| +**Parameters** + +| Name | Type | Mandatory | Description | +| --------------- | ------- | ---- | --------- | +| isPressed | boolean | Yes | Whether the key is pressed. | +| keyCode | Number | Yes | Key code. | +| keyDownDuration | boolean | Yes | Duration within which the key is pressed. | +| isIntercepted | Number | Yes | Whether the key can be intercepted.| diff --git a/en/application-dev/reference/apis/js-apis-inputmonitor.md b/en/application-dev/reference/apis/js-apis-inputmonitor.md index 6feb477120e3c128c26086b199faab2e5a5caede..6bbd043fd8eefaf4809c123e0b3fb465b9d59722 100644 --- a/en/application-dev/reference/apis/js-apis-inputmonitor.md +++ b/en/application-dev/reference/apis/js-apis-inputmonitor.md @@ -3,6 +3,7 @@ > **NOTE**
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> > - The APIs of this module are system APIs and cannot be called by third-party applications. @@ -29,7 +30,8 @@ Enables listening for global touch events. **System capability**: SystemCapability.MultimodalInput.Input.InputMonitor - **Parameters** +**Parameters** + | Name | Type | Mandatory| Description | | -------- | ----------------------------------------- | ---- | ------------------------------- | | type | string | Yes | Type of the input event to listen for. The value is **touch**.| @@ -52,7 +54,7 @@ Enables listening for global mouse events. **System capability**: SystemCapability.MultimodalInput.Input.InputMonitor - **Parameters** +**Parameters** | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------------------- | @@ -73,13 +75,14 @@ inputMonitor.off("mouse", (event) => { off(type: "touch", receiver?:TouchEventReceiver):void -Enables listening for global touch events. +Stops listening for global touch events. **Required permissions**: ohos.permission.INPUT_MONITORING **System capability**: SystemCapability.MultimodalInput.Input.InputMonitor - **Parameters** +**Parameters** + | Name | Type | Mandatory| Description | | -------- | ----------------------------------------- | ---- | ------------------------------- | | type | string | Yes | Type of the input event to listen for. The value is **touch**.| @@ -99,7 +102,7 @@ Stops listening for global mouse events. **System capability**: SystemCapability.MultimodalInput.Input.InputMonitor - **Parameters** +**Parameters** | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------------------- | @@ -116,7 +119,7 @@ inputMonitor.off("mouse"); ## TouchEventReceiver -Represents the class of the callback used to return the touch event. The value **true** indicates that the touch event has been consumed, and the value **false** indicates the opposite. +This class provides the callback of touch events. ### (touchEvent: TouchEvent): Boolean @@ -125,12 +128,14 @@ Represents the callback used to return the touch event. You need to define the n **System capability**: SystemCapability.MultimodalInput.Input.InputMonitor - **Parameters** +**Parameters** + | Name | Type | Mandatory | Description | | ---------- | ---------------------------------------- | ---- | ---------------------------------------- | | touchEvent | [TouchEvent](../arkui-js/js-components-common-events.md) | Yes | Callback used to return the touch event.| - **Return value** +**Return value** + | Type | Description | | ------- | -------------------------------------- | | Boolean | Result indicating whether the touch event has been consumed by the input monitor. The value **true** indicates that the touch event has been consumed, and the value **false** indicates the opposite.|