From ccd023ff1b45adea09fb703f6966b34c27970490 Mon Sep 17 00:00:00 2001 From: shaoziyun Date: Wed, 29 Jun 2022 03:23:52 +0000 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E6=A8=A1md=E6=96=87=E4=BB=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shaoziyun --- .../reference/apis/Readme-CN.md | 2 +- .../reference/apis/js-apis-inputconsumer.md | 29 +-- .../reference/apis/js-apis-inputdevice.md | 175 +++++++++--------- .../reference/apis/js-apis-inputevent.md | 4 +- .../apis/js-apis-inputeventclient.md | 11 +- .../reference/apis/js-apis-inputmonitor.md | 70 ++----- .../reference/apis/js-apis-keycode.md | 4 +- .../reference/apis/js-apis-keyevent.md | 2 +- 8 files changed, 132 insertions(+), 165 deletions(-) mode change 100644 => 100755 zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index eaff8fcc88..527fcf8cf6 100755 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -182,7 +182,7 @@ - [@ohos.multimodalInput.keyCode (键值)](js-apis-keycode.md) - [@ohos.multimodalInput.keyEvent (按键输入事件)](js-apis-keyevent.md) - [@ohos.multimodalInput.mouseEvent (鼠标输入事件)](js-apis-mouseevent.md) - - [@ohos.multimodalInput.ToucEvent (触摸输入事件)](js-apis-touchevent.md) + - [@ohos.multimodalInput.touchEvent (触摸输入事件)](js-apis-touchevent.md) - [@ohos.power (系统电源管理)](js-apis-power.md) - [@ohos.runningLock (Runninglock锁)](js-apis-runninglock.md) - [@ohos.sensor (传感器)](js-apis-sensor.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md b/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md index c0c68148d5..0a34cefa86 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md @@ -1,5 +1,6 @@ # 组合按键 +InputConsumer模块提供对按键事件的监听。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > @@ -18,19 +19,19 @@ import inputConsumer from '@ohos.multimodalInput.inputConsumer'; ## inputConsumer.on -on(type: "key", keyOptions: KeyOptions, callback: Callback): void +on(type: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>): void 开始监听组合按键事件, 当满足条件的组合按键输入事件发生时,将keyOptions回调到入参callback表示的回调函数上。 -**系统能力:** SystemCapability.MultimodalInput.Input.InputConsumer +此接口为系统接口。 **参数:** -| 参数 | 类型 | 必填 | 说明 | +| 参数 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| type | string | 是 | 监听输入事件类型,只支持“key”。 | -| keyOptions | [keyOptions](#keyOptions) | 是 | 组合键选项,用来指定组合键输入时应该符合的条件。 | -| callback | KeyOptions | 是 | 回调函数。当满足条件的按键输入产生时,回调到此函数,以传入的KeyOptions为入参。 | +| type | string | 是 | 监听输入事件类型,只支持“key”。 | +| keyOptions | [keyOptions](#keyOptions) | 是 | 组合键选项,用来指定组合键输入时应该符合的条件。 | +| callback | Callback<KeyOptions> | 是 | 回调函数。当满足条件的按键输入产生时,回调到此函数,以传入的KeyOptions为入参。 | **示例:** @@ -46,19 +47,21 @@ inputConsumer.on('key', keyOptions, callback); ## inputConsumer.off -off(type: "key", keyOptions: KeyOptions, callback?: Callback): void +off(type: "key", keyOptions: KeyOptions, callback?: Callback<KeyOptions>): void 停止监听组合按键事件。 +此接口为系统接口。 + **系统能力:** SystemCapability.MultimodalInput.Input.InputConsumer **参数:** -| 参数 | 类型 | 必填 | 说明 | +| 参数 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| type | string | 是 | 监听输入事件类型,只支持“key”。 | -| keyOptions | [keyOptions](#keyOptions) | 是 | 开始监听时传入的keyOptions。 | -| callback | Callback | 是 | 开始监听时与KeyOption一同传入的回调函数 。 | +| type | string | 是 | 监听输入事件类型,只支持“key”。 | +| keyOptions | [keyOptions](#keyOptions) | 是 | 开始监听时传入的keyOptions。 | +| callback | Callback<KeyOptions> | 是 | 开始监听时与KeyOption一同传入的回调函数 。 | **示例:** @@ -76,7 +79,9 @@ inputConsumer.off('key', keyOptions, callback); 组合键输入事件发生时,组合键满足的选项。 -**系统能力:** 以下各项对应系统能力均为SystemCapability.MultimodalInput.Input.InputConsumer +此接口为系统接口。 + +**系统能力:**SystemCapability.MultimodalInput.Input.InputConsumer | 参数 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md index 4cafe2e519..74d20ddb54 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @@ -4,8 +4,7 @@ 输入设备管理模块,用于监听输入设备连接、断开和变化,并查看输入设备相关信息。比如监听鼠标插拔,并获取鼠标的id、name和指针移动速度等信息。 -> **说明:** -> +> **说明**:
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -20,33 +19,33 @@ import inputDevice from '@ohos.multimodalInput.inputDevice'; on(type: “change”, listener: Callback<DeviceListener>): void -监听设备的热插拔事件。 +监听输入设备的热插拔事件。 -**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -**参数:** +**参数**: -| 参数 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------- | -| type | string | 是 | 输入设备的事件类型 | -| listener | Callback<[DeviceListener](#devicelistener)> | 是 | 可上报的输入设备事件 | +| 参数 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ----------- | +| type | string | 是 | 输入设备的事件类型。 | +| listener | Callback<[DeviceListener](#devicelistener9+)> | 是 | 可上报的输入设备事件。 | -**示例:** +**示例**: ```js let isPhysicalKeyboardExist = true; inputDevice.on("change", (data) => { - console.log("type: " + data.type + ", deviceId: " + data.deviceId); - inputDevice.getKeyboardType(data.deviceId, (ret) => { - console.log("The keyboard type of the device is: " + ret); - if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') { - // 监听物理键盘已连接。 - isPhysicalKeyboardExist = true; - } else if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'remove') { - // 监听物理键盘已断开。 - isPhysicalKeyboardExist = false; - } - }); + console.log("type: " + data.type + ", deviceId: " + data.deviceId); + inputDevice.getKeyboardType(data.deviceId, (err, ret) => { + console.log("The keyboard type of the device is: " + ret); + if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') { + // 监听物理键盘已连接。 + isPhysicalKeyboardExist = true; + } else if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'remove') { + // 监听物理键盘已断开。 + isPhysicalKeyboardExist = false; + } + }); }); // 根据isPhysicalKeyboardExist的值决定软键盘是否弹出。 ``` @@ -55,30 +54,30 @@ inputDevice.on("change", (data) => { off(type: “change”, listener?: Callback<DeviceListener>): void -取消监听设备的热插拔事件。 +取消监听输入设备的热插拔事件。 -**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -**参数:** +**参数**: -| 参数 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------- | -| type | string | 是 | 输入设备的事件类型 | -| listener | Callback<[DeviceListener](#devicelistener)> | 否 | 可上报的输入设备事件 | +| 参数 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ----------- | +| type | string | 是 | 输入设备的事件类型。 | +| listener | Callback<[DeviceListener](#devicelistener9+)> | 否 | 可上报的输入设备事件。 | -**示例:** +**示例**: ```js function listener(data) { - console.log("type: " + data.type + ", deviceId: " + data.deviceId); + console.log("type: " + data.type + ", deviceId: " + data.deviceId); } // 单独取消listener的监听。 inputDevice.off("change", listener); -// 取消所有监听 +// 取消所有监听。 inputDevice.off("change"); -// 取消监听后,软键盘默认都弹出 +// 取消监听后,软键盘默认都弹出。 ``` ## inputDevice.getDeviceIds @@ -87,15 +86,15 @@ getDeviceIds(callback: AsyncCallback<Array<number>>): void 获取所有输入设备的id列表,使用callback方式作为异步方法。 -**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -**参数:** +**参数**: | 参数 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ----- | | callback | AsyncCallback<Array<number>> | 是 | 回调函数。 | -**示例:** +**示例**: ```js inputDevice.getDeviceIds((ids)=>{ @@ -105,19 +104,19 @@ inputDevice.getDeviceIds((ids)=>{ ## inputDevice.getDeviceIds -function getDeviceIds(): Promise<<Array<number>> +getDeviceIds(): Promise<Array<number>> 获取所有输入设备的id列表,使用Promise方式作为异步方法。 -**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -**返回值:** +**返回值**: -| 参数 | 说明 | -| ---------------------------------- | ------------------ | -| Promise<Array<number>> | Promise实例,用于异步获取结果 | +| 参数 | 说明 | +| ---------------------------------- | ------------------- | +| Promise<Array<number>> | Promise实例,用于异步获取结果。 | -**示例:** +**示例**: ```js inputDevice.getDeviceIds().then((ids)=>{ @@ -131,16 +130,16 @@ getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): voi 获取输入设备的描述信息,使用callback方式作为异步方法。 -**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -**参数:** +**参数**: | 参数 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | --------------------------- | | deviceId | number | 是 | 需要获取信息的设备id。 | | callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | 是 | 回调函数,异步返回InputDeviceData对象。 | -**示例:** +**示例**: ```js // 示例获取设备id为1的设备name信息。 @@ -151,25 +150,25 @@ inputDevice.getDevice(1, (inputDevice)=>{ ## inputDevice.getDevice -function getDevice(deviceId: number): Promise<InputDeviceData> +getDevice(deviceId: number): Promise<InputDeviceData> 获取输入设备的描述信息,使用Promise方式作为异步方法。 -**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -**参数:** +**参数**: | 参数 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------ | | deviceId | number | 是 | 需要获取信息的设备id。 | -**返回值:** +**返回值**: -| 参数 | 说明 | -| ---------------------------------------- | ------------------ | -| Promise<[InputDeviceData](#inputdevicedata)> | Promise实例,用于异步获取结果 | +| 参数 | 说明 | +| ---------------------------------------- | ------------------- | +| Promise<[InputDeviceData](#inputdevicedata)> | Promise实例,用于异步获取结果。 | -**示例:** +**示例**: ```js // 示例获取设备id为1的设备name信息。 @@ -180,13 +179,13 @@ inputDevice.getDevice(1).then((inputDevice)=>{ ## inputDevice.supportKeys9+ -supportKeys(deviceId: number, keys: Array<KeyCode>, callback: Callback<Array<boolean>>): void; +supportKeys(deviceId: number, keys: Array<KeyCode>, callback: Callback<Array<boolean>>): void -获取输入设备的描述信息,使用callback方式作为异步方法。 +获取输入设备支持的键码值,使用callback方式作为异步方法。 -**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -**参数:** +**参数**: | 参数 | 类型 | 必填 | 说明 | | -------- | ------------------------------------ | ---- | --------------------------------- | @@ -194,7 +193,7 @@ supportKeys(deviceId: number, keys: Array<KeyCode>, callback: Callback< | keys | Array<KeyCode> | 是 | 需要查询的键码值,最多支持5个按键查询。 | | callback | Callback<Array<boolean>> | 是 | 回调函数,异步返回查询结果。 | -**示例:** +**示例**: ```js // 示例查询id为1的设备对于17、22和2055按键的支持情况。 @@ -205,26 +204,26 @@ inputDevice.supportKeys(1, [17, 22, 2055], (ret)=>{ ## inputDevice.supportKeys9+ -supportKeys(deviceId: number, keys: Array<KeyCode>): Promise<Array<boolean>>; +supportKeys(deviceId: number, keys: Array<KeyCode>): Promise<Array<boolean>> -获取输入设备的描述信息,使用Promise方式作为异步方法。 +获取输入设备支持的键码值,使用Promise方式作为异步方法。 -**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -**参数:** +**参数**: | 参数 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | --------------------------------- | | deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 | | keys | Array<KeyCode> | 是 | 需要查询的键码值,最多支持5个按键查询。 | -**返回值:** +**返回值**: -| 参数 | 说明 | -| ----------------------------------- | ------------------ | -| Promise<Array<boolean>> | Promise实例,用于异步获取结果 | +| 参数 | 说明 | +| ----------------------------------- | ------------------- | +| Promise<Array<boolean>> | Promise实例,用于异步获取结果。 | -**示例:** +**示例**: ```js // 示例查询id为1的设备对于17、22和2055按键的支持情况。 @@ -235,20 +234,20 @@ inputDevice.supportKeys(1, [17, 22, 2055]).then((ret)=>{ ## inputDevice.getKeyboardType9+ -getKeyboardType(deviceId: number, callback: AsyncCallback<KeyboardType>): void; +getKeyboardType(deviceId: number, callback: AsyncCallback<KeyboardType>): void 查询输入设备的键盘类型,使用callback方式作为异步方法。 -**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -**参数:** +**参数**: | 参数 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | --------------------------------- | | deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 | | callback | AsyncCallback<[KeyboardType](#keyboardtype)> | 是 | 回调函数,异步返回查询结果。 | -**示例:** +**示例**: ```js // 示例查询设备id为1的设备键盘类型。 @@ -259,19 +258,19 @@ inputDevice.getKeyboardType(1, (ret)=>{ ## inputDevice.getKeyboardType9+ -getKeyboardType(deviceId: number,): Promise<KeyboardType>; +getKeyboardType(deviceId: number): Promise<KeyboardType> 查询输入设备的键盘类型,使用Promise方式作为异步方法。 -**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -**返回值:** +**返回值**: -| 参数 | 说明 | -| ---------------------------------------- | ------------------ | -| Promise<[KeyboardType](#keyboardtype)> | Promise实例,用于异步获取结果 | +| 参数 | 说明 | +| ---------------------------------------- | ------------------- | +| Promise<[KeyboardType](#keyboardtype)> | Promise实例,用于异步获取结果。 | -**示例:** +**示例**: ```js // 示例查询设备id为1的设备键盘类型。 @@ -284,7 +283,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{ 输入设备的描述信息。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice | 名称 | 参数类型 | 说明 | | -------- | --------------------------- | --------------------------------- | @@ -295,7 +294,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{ 输入设备的描述信息。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice | 名称 | 参数类型 | 说明 | | -------------------- | -------------------------------------- | ---------------------------------------- | @@ -312,9 +311,9 @@ inputDevice.getKeyboardType(1).then((ret)=>{ ## AxisType9+ -输入设备的轴类型 +输入设备的轴类型。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice | 名称 | 参数类型 | 说明 | | ----------- | ------ | --------------- | @@ -330,14 +329,14 @@ inputDevice.getKeyboardType(1).then((ret)=>{ ## AxisRange -输入设备的轴信息 +输入设备的轴信息。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**: 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice | 名称 | 参数类型 | 说明 | | ----------------------- | ------------------------- | -------- | | source | [SourceType](#sourcetype) | 轴的输入源类型。 | -| axis | [AxisType](axistype) | 轴的类型。 | +| axis | [AxisType](#axistype) | 轴的类型。 | | max | number | 轴的最大值。 | | min | number | 轴的最小值。 | | fuzz9+ | number | 轴的模糊值。 | @@ -348,7 +347,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{ 定义这个轴的输入源类型。比如鼠标设备可上报x轴事件,则x轴的源就是鼠标。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice | 名称 | 参数类型 | 说明 | | ----------- | ------ | ----------- | @@ -363,7 +362,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{ 定义监听设备热插拔事件。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice | 名称 | 参数类型 | 说明 | | ------ | ------ | --------- | @@ -374,7 +373,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{ 定义键盘输入设备的类型。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice | 名称 | 参数类型 | 值 | 说明 | | ------------------- | ------ | ---- | --------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputevent.md b/zh-cn/application-dev/reference/apis/js-apis-inputevent.md index a039363b77..01aaa9b2ba 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputevent.md @@ -1,6 +1,6 @@ # 输入事件 -设备上报的基本事件。 +InputEvent模块描述了设备上报的基本事件。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -11,6 +11,8 @@ import InputEvent from '@ohos.multimodalInput.inputEvent'; ``` +## InputEvent + **系统能力**:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.Core | 名称 | 参数类型 | 可读 | 可写 | 描述 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md b/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md old mode 100644 new mode 100755 index f614779f4e..d199635658 --- a/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md @@ -1,5 +1,6 @@ # 注入按键 +InputEventClient模块提供了注入按键能力。 > **说明:** > @@ -22,6 +23,8 @@ injectEvent({KeyEvent: KeyEvent}): void 注入按键,KeyEvent为注入按键的描述信息。 +此接口为系统接口。 + **系统能力:** SystemCapability.MultimodalInput.Input.InputSimulator **参数:** @@ -47,11 +50,13 @@ let res = inputEventClient.injectEvent({KeyEvent: keyEvent}); 注入按键的描述信息 +此接口为系统接口。 + **系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputSimulator | 参数 | 类型 | 必填 | 说明 | | --------------- | ------- | ---- | --------- | | isPressed | boolean | 是 | 按键是否按下 | -| keyCode | Number | 是 | 按键键值 | -| keyDownDuration | boolean | 是 | 按键按下持续时间 | -| isIntercepted | Number | 是 | 按键是否可以被拦截 | +| keyCode | number | 是 | 按键键值 | +| keyDownDuration | number | 是 | 按键按下持续时间 | +| isIntercepted | boolean | 是 | 按键是否可以被拦截 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md index 4088e77cc6..779433381b 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md @@ -1,5 +1,6 @@ # 输入监听 +InputMonitor模块提供了监听全局触摸事件的功能。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -26,6 +27,8 @@ on(type: "touch", receiver: TouchEventReceiver): void 开始监听全局触屏事件。 +此接口为系统接口。 + **需要权限:**ohos.permission.INPUT_MONITORING **系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor @@ -45,36 +48,13 @@ inputMonitor.off("touch", (event) => { }); ``` -on(type: "mouse", receiver: TouchEventReceiver): void - -开始监听全局鼠标事件。 - -**需要权限:** ohos.permission.INPUT_MONITORING - -**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor - - **参数:** - -| 参数 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------------- | -| type | string | 是 | 监听输入事件类型,取值“mouse”。 | -| receiver | Callback | 是 | 鼠标输入事件回调函数。 | - - **示例:** - -```js -inputMonitor.off("mouse", (event) => { - // 消费鼠标事件 -}); -``` - - - ## inputMonitor.off -off(type: "touch", receiver: TouchEventReceiver): void +off(type: "touch", receiver?: TouchEventReceiver): void -开始监听全局触屏事件。 +停止监听全局触屏事件。 + +此接口为系统接口。 **需要权限:**ohos.permission.INPUT_MONITORING @@ -92,37 +72,11 @@ off(type: "touch", receiver: TouchEventReceiver): void inputMonitor.off("touch"); ``` -off(type: "mouse", receiver?: Callback): void - -停止监听全局鼠标事件。 - -**需要权限:**ohos.permission.INPUT_MONITORING - -**系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor - - **参数:** - -| 参数 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------------- | -| type | string | 是 | 监听输入事件类型,取值“mouse”。 | -| receiver | Callback | 否 | 鼠标输入事件回调函数。 | - -**示例:** - -```js -inputMonitor.off("mouse"); -``` - - - ## TouchEventReceiver -触摸输入事件的回调函数,如果返回true,则触摸输入将被监听器消耗(系统执行关闭动作)。 - +触摸输入事件的回调函数。如果返回true,则触摸输入被监听器消耗,系统将执行关闭动作。 -### (touchEvent: TouchEvent): Boolean - -触摸输入事件的回调函数。函数名由使用者定义,这里是函数调用时必须符合的格式,传入参数必须为TouchEvent类型,返回值为Boolean类型。 +此接口为系统接口。 **系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor @@ -132,15 +86,15 @@ inputMonitor.off("mouse"); | touchEvent | [TouchEvent](../arkui-js/js-components-common-events.md) | 是 | 触摸输入事件回调函数,返回true表示输触事件被监听器消费,false表示输触事件未被监听器消费。 | **返回值:** -| 类型 | 说明 | +| 类型 | 说明 | | ------- | -------------------------------------- | -| Boolean | 返回true表示输触事件被监听器消费,false表示输触事件未被监听器消费。 | +| Boolean | 返回true表示触摸输入事件被监听器消费,false表示触摸输入事件未被监听器消费。 | **示例:** ```js inputMonitor.on("touch", (event) => { - // 消费触屏事件 + // 消费触摸输入事件 return false; }); inputMonitor.off("touch"); diff --git a/zh-cn/application-dev/reference/apis/js-apis-keycode.md b/zh-cn/application-dev/reference/apis/js-apis-keycode.md index b7022e48fb..2559bcf9dc 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-keycode.md +++ b/zh-cn/application-dev/reference/apis/js-apis-keycode.md @@ -1,6 +1,6 @@ # 键值 -按键类设备键值。 +KeyCode模块提供了按键类设备的键值。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -11,6 +11,8 @@ import {KeyCode} from '@ohos.multimodalInput.keyCode' ``` +## KeyCode + **系统能力**:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.Core | 名称 | 参数类型 | 可读 | 可写 | 描述 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-keyevent.md b/zh-cn/application-dev/reference/apis/js-apis-keyevent.md index 4252faf2be..a2d63e44c6 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-keyevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-keyevent.md @@ -1,6 +1,6 @@ # 按键输入事件 -设备上报的按键事件。 +KeyEvent模块提供了设备可以上报的按键事件。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -- GitLab