未验证 提交 6d443a81 编写于 作者: O openharmony_ci 提交者: Gitee

!5171 翻译已完成4641

Merge pull request !5171 from shawn_he/4641-a
...@@ -191,6 +191,7 @@ ...@@ -191,6 +191,7 @@
- [@ohos.multimodalInput.inputDevice](js-apis-inputdevice.md) - [@ohos.multimodalInput.inputDevice](js-apis-inputdevice.md)
- [@ohos.multimodalInput.inputEventClient](js-apis-inputeventclient.md) - [@ohos.multimodalInput.inputEventClient](js-apis-inputeventclient.md)
- [@ohos.multimodalInput.inputMonitor](js-apis-inputmonitor.md) - [@ohos.multimodalInput.inputMonitor](js-apis-inputmonitor.md)
- [@ohos.multimodalInput.inputEvent](js-apis-inputevent.md)
- [@ohos.power](js-apis-power.md) - [@ohos.power](js-apis-power.md)
- [@ohos.runningLock](js-apis-runninglock.md) - [@ohos.runningLock](js-apis-runninglock.md)
- [@ohos.sensor](js-apis-sensor.md) - [@ohos.sensor](js-apis-sensor.md)
......
# Combination Key # Combination Key
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
>
> - 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.
...@@ -17,66 +18,71 @@ import inputConsumer from '@ohos.multimodalInput.inputConsumer'; ...@@ -17,66 +18,71 @@ import inputConsumer from '@ohos.multimodalInput.inputConsumer';
## inputConsumer.on ## inputConsumer.on
on(type: "key", keyOption: KeyOption, callback: Callback&lt;KeyOption&gt;): void on(type: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>): 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 **System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
**Parameters** **Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the key input event to listen for. Only **key** is supported. | | 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. | | keyOptions | [keyOptions](#keyOptions) | Yes| Key option, which specifies the condition for combination key input.|
| callback | Callback&lt;KeyOption&gt; | Yes | Callback function. When a key input event that meets the specified options occurs, **keyOption** will be passed as an input parameter to **callback**. | | callback | KeyOptions | Yes| Callback used to return the result.<br> 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 keyOptions = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0}
let callback = function(keyOption) { let callback = function(keyOptions) {
console.info("preKeys: " + keyOption.preKeys, "finalKey: " + keyOption.finalKey, console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOption.isFinalKeyDown, "finalKeyDownDuration: " + keyOption.finalKeyDownDuration) "isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
} }
inputConsumer.on('key', keyOption, callback); inputConsumer.on('key', keyOptions, callback);
``` ```
## inputConsumer.off ## inputConsumer.off
off(type: "key", keyOption: KeyOption, callback: Callback&lt;KeyOption&gt;): void off(type: "key", keyOptions: KeyOptions, callback?: Callback<KeyOptions>): void
Stops listening for combination key events. Stops listening for combination key events.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer **System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
**Parameters** **Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the key input event to listen for. Only **key** is supported. | | 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. | | keyOptions | [keyOptions](#keyOptions) | Yes| Key options passed to the key input event when listening starts.|
| callback | Callback&lt;KeyOption&gt; | Yes | Callback function passed to the key input event with the key option when listening starts. | | callback | Callback<KeyOptions> | 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 keyOptions = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0}
let callback = function(keyOption) { let callback = function(keyOptions) {
console.info("preKeys: " + keyOption.preKeys, "finalKey: " + keyOption.finalKey, console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOption.isFinalKeyDown, "finalKeyDownDuration: " + keyOption.finalKeyDownDuration) "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. Defines the key options that are met when a combination key input event occurs.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer **System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
| Name | Type | Mandatory | Description |
**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. | | 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. | | 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. | | 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. | | finalKeyDownDuration | Number | Yes| Duration for pressing the final key. By default, there is no requirement on the duration.|
# Input Event
> **NOTE**<br>
> 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.|
# Input Event Client # Key Injection
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> >
> - 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 ## Modules to Import
``` ```js
import inputEventClient from '@ohos.multimodalInput.inputEventClient'; import inputEventClient from '@ohos.multimodalInput.inputEventClient';
``` ```
...@@ -20,38 +20,40 @@ import inputEventClient from '@ohos.multimodalInput.inputEventClient'; ...@@ -20,38 +20,40 @@ import inputEventClient from '@ohos.multimodalInput.inputEventClient';
injectEvent({KeyEvent: KeyEvent}): void injectEvent({KeyEvent: KeyEvent}): void
Injects a key. Injects a key event.
**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator **System capability**: SystemCapability.MultimodalInput.Input.InputSimulator
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | --------------------- | ---- | --------- |
| KeyEvent | [KeyEvent](#keyevent) | Yes| Information about the key to inject.| | KeyEvent | [KeyEvent](#keyevent) | Yes | Information about the key event to inject.|
**Example** **Example**
``` ```js
let keyEvent = { let keyEvent = {
isPressed: true, isPressed: true,
keyCode: 2, keyCode: 2,
keyDownDuration: 0, keyDownDuration: 0,
isIntercepted: false isIntercepted: false
} }
res = inputEventClient.injectEvent({KeyEvent: keyEvent}); let res = inputEventClient.injectEvent({KeyEvent: 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 **System capability**: SystemCapability.MultimodalInput.Input.InputSimulator
| Name| Type| Mandatory| Description| **Parameters**
| -------- | -------- | -------- | -------- |
| isPressed | boolean | Yes| Whether the key is pressed.| | Name | Type | Mandatory | Description |
| keyCode | Number | Yes| Key code.| | --------------- | ------- | ---- | --------- |
| keyDownDuration | boolean | Yes| Duration for which the key is pressed.| | isPressed | boolean | Yes | Whether the key is pressed. |
| isIntercepted | Number | Yes| Whether the key can be intercepted.| | keyCode | Number | Yes | Key code. |
| keyDownDuration | boolean | Yes | Duration within which the key is pressed. |
| isIntercepted | Number | Yes | Whether the key can be intercepted.|
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
> **NOTE**<br> > **NOTE**<br>
> - 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 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. > - 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. ...@@ -29,7 +30,8 @@ Enables listening for global touch events.
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor **System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | ------------------------------- | | -------- | ----------------------------------------- | ---- | ------------------------------- |
| type | string | Yes | Type of the input event to listen for. The value is **touch**.| | 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. ...@@ -52,7 +54,7 @@ Enables listening for global mouse events.
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor **System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------- | | -------- | -------------------- | ---- | ------------------------------- |
...@@ -73,13 +75,14 @@ inputMonitor.off("mouse", (event) => { ...@@ -73,13 +75,14 @@ inputMonitor.off("mouse", (event) => {
off(type: "touch", receiver?:TouchEventReceiver):void off(type: "touch", receiver?:TouchEventReceiver):void
Enables listening for global touch events. Stops listening for global touch events.
**Required permissions**: ohos.permission.INPUT_MONITORING **Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor **System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | ------------------------------- | | -------- | ----------------------------------------- | ---- | ------------------------------- |
| type | string | Yes | Type of the input event to listen for. The value is **touch**.| | 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. ...@@ -99,7 +102,7 @@ Stops listening for global mouse events.
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor **System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------- | | -------- | -------------------- | ---- | ------------------------------- |
...@@ -116,7 +119,7 @@ inputMonitor.off("mouse"); ...@@ -116,7 +119,7 @@ inputMonitor.off("mouse");
## TouchEventReceiver ## 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 ### (touchEvent: TouchEvent): Boolean
...@@ -125,12 +128,14 @@ Represents the callback used to return the touch event. You need to define the n ...@@ -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 **System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------- | ---------------------------------------- | ---- | ---------------------------------------- | | ---------- | ---------------------------------------- | ---- | ---------------------------------------- |
| touchEvent | [TouchEvent](../arkui-js/js-components-common-events.md) | Yes | Callback used to return the touch event.| | touchEvent | [TouchEvent](../arkui-js/js-components-common-events.md) | Yes | Callback used to return the touch event.|
**Return value** **Return value**
| Type | Description | | 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.| | 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.|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册