未验证 提交 167089e5 编写于 作者: K king_he 提交者: Gitee

update zh-cn/application-dev/reference/apis/js-apis-inputdevice.md.

Signed-off-by: Nking_he <6384784@qq.com>
上级 2b553b6e
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
输入设备管理模块,用于监听输入设备连接、断开和变化,并查看输入设备相关信息。比如监听鼠标插拔,并获取鼠标的id、name和指针移动速度等信息。 输入设备管理模块,用于监听输入设备连接、断开和变化,并查看输入设备相关信息。比如监听鼠标插拔,并获取鼠标的id、name和指针移动速度等信息。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > **说明**:<br>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...@@ -21,16 +21,16 @@ on(type: “change”, listener: Callback&lt;DeviceListener&gt;): void ...@@ -21,16 +21,16 @@ on(type: “change”, listener: Callback&lt;DeviceListener&gt;): void
监听设备的热插拔事件。 监听设备的热插拔事件。
**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice **系统能力**SystemCapability.MultimodalInput.Input.InputDevice
**参数:** **参数**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------- | ---- | -------------------- | | -------- | ------------------------------------------------- | ---- | -------------------- |
| type | string | 是 | 输入设备的事件类型 | | type | string | 是 | 输入设备的事件类型 |
| listener | Callback&lt;[DeviceListener](#devicelistener<sup>9+</sup>)&gt; | 是 | 可上报的输入设备事件 | | listener | Callback&lt;[DeviceListener](#devicelistener<sup>9+</sup>)&gt; | 是 | 可上报的输入设备事件 |
**示例:** **示例**
```js ```js
let isPhysicalKeyboardExist = true; let isPhysicalKeyboardExist = true;
...@@ -56,16 +56,16 @@ off(type: “change”, listener?: Callback&lt;DeviceListener&gt;): void ...@@ -56,16 +56,16 @@ off(type: “change”, listener?: Callback&lt;DeviceListener&gt;): void
取消监听设备的热插拔事件。 取消监听设备的热插拔事件。
**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice **系统能力**SystemCapability.MultimodalInput.Input.InputDevice
**参数:** **参数**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------- | ---- | -------------------- | | -------- | ------------------------------------------------- | ---- | -------------------- |
| type | string | 是 | 输入设备的事件类型 | | type | string | 是 | 输入设备的事件类型 |
| listener | Callback&lt;[DeviceListener](#devicelistener<sup>9+</sup>)&gt; | 否 | 可上报的输入设备事件 | | listener | Callback&lt;[DeviceListener](#devicelistener<sup>9+</sup>)&gt; | 否 | 可上报的输入设备事件 |
**示例:** **示例**
```js ```js
listener: function(data) { listener: function(data) {
...@@ -75,9 +75,9 @@ listener: function(data) { ...@@ -75,9 +75,9 @@ listener: function(data) {
// 单独取消listener的监听。 // 单独取消listener的监听。
inputDevice.off("change", this.listener); inputDevice.off("change", this.listener);
// 取消所有监听 // 取消所有监听
inputDevice.off("change"); inputDevice.off("change");
// 取消监听后,软键盘默认都弹出 // 取消监听后,软键盘默认都弹出
``` ```
## inputDevice.getDeviceIds ## inputDevice.getDeviceIds
...@@ -86,15 +86,15 @@ getDeviceIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void ...@@ -86,15 +86,15 @@ getDeviceIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
获取所有输入设备的id列表,使用callback方式作为异步方法。 获取所有输入设备的id列表,使用callback方式作为异步方法。
**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice **系统能力**SystemCapability.MultimodalInput.Input.InputDevice
**参数:** **参数**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ----- | | -------- | ---------------------------------------- | ---- | ----- |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是 | 回调函数。 | | callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是 | 回调函数。 |
**示例:** **示例**
```js ```js
inputDevice.getDeviceIds((ids)=>{ inputDevice.getDeviceIds((ids)=>{
...@@ -108,15 +108,15 @@ function getDeviceIds(): Promise&lt;&lt;Array&lt;number&gt;&gt; ...@@ -108,15 +108,15 @@ function getDeviceIds(): Promise&lt;&lt;Array&lt;number&gt;&gt;
获取所有输入设备的id列表,使用Promise方式作为异步方法。 获取所有输入设备的id列表,使用Promise方式作为异步方法。
**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice **系统能力**SystemCapability.MultimodalInput.Input.InputDevice
**返回值:** **返回值**
| 参数 | 说明 | | 参数 | 说明 |
| ------------------------- | ----------------------------- | | ------------------------- | ----------------------------- |
| Promise&lt;Array&lt;number&gt;&gt; | Promise实例,用于异步获取结果 | | Promise&lt;Array&lt;number&gt;&gt; | Promise实例,用于异步获取结果 |
**示例:** **示例**
```js ```js
inputDevice.getDeviceIds().then((ids)=>{ inputDevice.getDeviceIds().then((ids)=>{
...@@ -130,16 +130,16 @@ getDevice(deviceId: number, callback: AsyncCallback&lt;InputDeviceData&gt;): voi ...@@ -130,16 +130,16 @@ getDevice(deviceId: number, callback: AsyncCallback&lt;InputDeviceData&gt;): voi
获取输入设备的描述信息,使用callback方式作为异步方法。 获取输入设备的描述信息,使用callback方式作为异步方法。
**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice **系统能力**SystemCapability.MultimodalInput.Input.InputDevice
**参数:** **参数**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | --------------------------- | | -------- | ---------------------------------------- | ---- | --------------------------- |
| deviceId | number | 是 | 需要获取信息的设备id。 | | deviceId | number | 是 | 需要获取信息的设备id。 |
| callback | AsyncCallback&lt;[InputDeviceData](#inputdevicedata)&gt; | 是 | 回调函数,异步返回InputDeviceData对象。 | | callback | AsyncCallback&lt;[InputDeviceData](#inputdevicedata)&gt; | 是 | 回调函数,异步返回InputDeviceData对象。 |
**示例:** **示例**
```js ```js
// 示例获取设备id为1的设备name信息。 // 示例获取设备id为1的设备name信息。
...@@ -154,21 +154,21 @@ function getDevice(deviceId: number): Promise&lt;InputDeviceData&gt; ...@@ -154,21 +154,21 @@ function getDevice(deviceId: number): Promise&lt;InputDeviceData&gt;
获取输入设备的描述信息,使用Promise方式作为异步方法。 获取输入设备的描述信息,使用Promise方式作为异步方法。
**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice **系统能力**SystemCapability.MultimodalInput.Input.InputDevice
**参数:** **参数**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---------------------- | | -------- | ------ | ---- | ---------------------- |
| deviceId | number | 是 | 需要获取信息的设备id。 | | deviceId | number | 是 | 需要获取信息的设备id。 |
**返回值:** **返回值**
| 参数 | 说明 | | 参数 | 说明 |
| -------------------------------------------------- | ----------------------------- | | -------------------------------------------------- | ----------------------------- |
| Promise&lt;[InputDeviceData](#inputdevicedata)&gt; | Promise实例,用于异步获取结果 | | Promise&lt;[InputDeviceData](#inputdevicedata)&gt; | Promise实例,用于异步获取结果 |
**示例:** **示例**
```js ```js
// 示例获取设备id为1的设备name信息。 // 示例获取设备id为1的设备name信息。
...@@ -181,11 +181,11 @@ inputDevice.getDevice(1).then((inputDevice)=>{ ...@@ -181,11 +181,11 @@ inputDevice.getDevice(1).then((inputDevice)=>{
supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;, callback: Callback&lt;Array&lt;boolean&gt;&gt;): void; supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;, callback: Callback&lt;Array&lt;boolean&gt;&gt;): void;
获取输入设备的描述信息,使用callback方式作为异步方法。 获取输入设备支持的键码值,使用callback方式作为异步方法。
**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice **系统能力**SystemCapability.MultimodalInput.Input.InputDevice
**参数:** **参数**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
...@@ -193,7 +193,7 @@ supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;, callback: Callback&lt; ...@@ -193,7 +193,7 @@ supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;, callback: Callback&lt;
| keys | Array&lt;KeyCode&gt; | 是 | 需要查询的键码值,最多支持5个按键查询。 | | keys | Array&lt;KeyCode&gt; | 是 | 需要查询的键码值,最多支持5个按键查询。 |
| callback | Callback&lt;Array&lt;boolean&gt;&gt; | 是 | 回调函数,异步返回查询结果。 | | callback | Callback&lt;Array&lt;boolean&gt;&gt; | 是 | 回调函数,异步返回查询结果。 |
**示例:** **示例**
```js ```js
// 示例查询id为1的设备对于17、22和2055按键的支持情况。 // 示例查询id为1的设备对于17、22和2055按键的支持情况。
...@@ -206,24 +206,24 @@ inputDevice.supportKeys(1, [17, 22, 2055], (ret)=>{ ...@@ -206,24 +206,24 @@ inputDevice.supportKeys(1, [17, 22, 2055], (ret)=>{
supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;): Promise&lt;Array&lt;boolean&gt;&gt; supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;): Promise&lt;Array&lt;boolean&gt;&gt;
获取输入设备的描述信息,使用Promise方式作为异步方法。 获取输入设备支持的键码值,使用Promise方式作为异步方法。
**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice **系统能力**SystemCapability.MultimodalInput.Input.InputDevice
**参数:** **参数**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------------------------------------ | | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 | | deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| keys | Array&lt;KeyCode&gt; | 是 | 需要查询的键码值,最多支持5个按键查询。 | | keys | Array&lt;KeyCode&gt; | 是 | 需要查询的键码值,最多支持5个按键查询。 |
**返回值:** **返回值**
| 参数 | 说明 | | 参数 | 说明 |
| ----------------------------------- | ----------------------------- | | ----------------------------------- | ----------------------------- |
| Promise&lt;Array&lt;boolean&gt;&gt; | Promise实例,用于异步获取结果 | | Promise&lt;Array&lt;boolean&gt;&gt; | Promise实例,用于异步获取结果 |
**示例:** **示例**
```js ```js
// 示例查询id为1的设备对于17、22和2055按键的支持情况。 // 示例查询id为1的设备对于17、22和2055按键的支持情况。
...@@ -238,16 +238,16 @@ getKeyboardType(deviceId: number, callback: AsyncCallback&lt;KeyboardType&gt;): ...@@ -238,16 +238,16 @@ getKeyboardType(deviceId: number, callback: AsyncCallback&lt;KeyboardType&gt;):
查询输入设备的键盘类型,使用callback方式作为异步方法。 查询输入设备的键盘类型,使用callback方式作为异步方法。
**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice **系统能力**SystemCapability.MultimodalInput.Input.InputDevice
**参数:** **参数**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ |
| deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 | | deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| callback | AsyncCallback&lt;[KeyboardType](#keyboardtype)&gt; | 是 | 回调函数,异步返回查询结果。 | | callback | AsyncCallback&lt;[KeyboardType](#keyboardtype)&gt; | 是 | 回调函数,异步返回查询结果。 |
**示例:** **示例**
```js ```js
// 示例查询设备id为1的设备键盘类型。 // 示例查询设备id为1的设备键盘类型。
...@@ -262,15 +262,15 @@ getKeyboardType(deviceId: number,): Promise&lt;KeyboardType&gt;; ...@@ -262,15 +262,15 @@ getKeyboardType(deviceId: number,): Promise&lt;KeyboardType&gt;;
查询输入设备的键盘类型,使用Promise方式作为异步方法。 查询输入设备的键盘类型,使用Promise方式作为异步方法。
**系统能力:** SystemCapability.MultimodalInput.Input.InputDevice **系统能力**SystemCapability.MultimodalInput.Input.InputDevice
**返回值:** **返回值**
| 参数 | 说明 | | 参数 | 说明 |
| -------------------------------------------- | ----------------------------- | | -------------------------------------------- | ----------------------------- |
| Promise&lt;[KeyboardType](#keyboardtype)&gt; | Promise实例,用于异步获取结果 | | Promise&lt;[KeyboardType](#keyboardtype)&gt; | Promise实例,用于异步获取结果 |
**示例:** **示例**
```js ```js
// 示例查询设备id为1的设备键盘类型。 // 示例查询设备id为1的设备键盘类型。
...@@ -283,7 +283,7 @@ inputDevice.getKeyboardType().then((ret)=>{ ...@@ -283,7 +283,7 @@ inputDevice.getKeyboardType().then((ret)=>{
输入设备的描述信息。 输入设备的描述信息。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice **系统能力**以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 | | 名称 | 参数类型 | 说明 |
| -------- | --------------------------- | ------------------------------------------------------------ | | -------- | --------------------------- | ------------------------------------------------------------ |
...@@ -294,7 +294,7 @@ inputDevice.getKeyboardType().then((ret)=>{ ...@@ -294,7 +294,7 @@ inputDevice.getKeyboardType().then((ret)=>{
输入设备的描述信息。 输入设备的描述信息。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice **系统能力**以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 | | 名称 | 参数类型 | 说明 |
| -------------------- | -------------------------------------- | ------------------------------------------------------------ | | -------------------- | -------------------------------------- | ------------------------------------------------------------ |
...@@ -313,7 +313,7 @@ inputDevice.getKeyboardType().then((ret)=>{ ...@@ -313,7 +313,7 @@ inputDevice.getKeyboardType().then((ret)=>{
输入设备的轴类型 输入设备的轴类型
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice **系统能力**以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 | | 名称 | 参数类型 | 说明 |
| ----------- | -------- | ------------------- | | ----------- | -------- | ------------------- |
...@@ -331,7 +331,7 @@ inputDevice.getKeyboardType().then((ret)=>{ ...@@ -331,7 +331,7 @@ inputDevice.getKeyboardType().then((ret)=>{
输入设备的轴信息 输入设备的轴信息
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice **系统能力** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 | | 名称 | 参数类型 | 说明 |
| ----------------------- | ------------------------- | ---------------- | | ----------------------- | ------------------------- | ---------------- |
...@@ -347,7 +347,7 @@ inputDevice.getKeyboardType().then((ret)=>{ ...@@ -347,7 +347,7 @@ inputDevice.getKeyboardType().then((ret)=>{
定义这个轴的输入源类型。比如鼠标设备可上报x轴事件,则x轴的源就是鼠标。 定义这个轴的输入源类型。比如鼠标设备可上报x轴事件,则x轴的源就是鼠标。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice **系统能力**以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 | | 名称 | 参数类型 | 说明 |
| ----------- | ------ | ----------- | | ----------- | ------ | ----------- |
...@@ -362,7 +362,7 @@ inputDevice.getKeyboardType().then((ret)=>{ ...@@ -362,7 +362,7 @@ inputDevice.getKeyboardType().then((ret)=>{
定义监听设备热插拔事件。 定义监听设备热插拔事件。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice **系统能力**以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 | | 名称 | 参数类型 | 说明 |
| ------ | -------- | ------------------ | | ------ | -------- | ------------------ |
...@@ -373,7 +373,7 @@ inputDevice.getKeyboardType().then((ret)=>{ ...@@ -373,7 +373,7 @@ inputDevice.getKeyboardType().then((ret)=>{
定义键盘输入设备的类型。 定义键盘输入设备的类型。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice **系统能力**以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 值 | 说明 | | 名称 | 参数类型 | 值 | 说明 |
| ------------------- | -------- | ---- | ------------------ | | ------------------- | -------- | ---- | ------------------ |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册