diff --git a/zh-cn/application-dev/reference/apis/js-apis-cooperate.md b/zh-cn/application-dev/reference/apis/js-apis-cooperate.md index dc0a2d34093370ec0f36c32db957d5d50edd250a..c3974d38632d10da466d33739aaa260a6f7ffc49 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-cooperate.md +++ b/zh-cn/application-dev/reference/apis/js-apis-cooperate.md @@ -112,6 +112,8 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCal **示例**: ```js +let sinkDeviceDescriptor = "descriptor"; +let srcInputDeviceId = 0; try { inputDeviceCooperate.start(sinkDeviceDescriptor, srcInputDeviceId, (error) => { if (error) { @@ -160,6 +162,8 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise\ **示例**: ```js +let sinkDeviceDescriptor = "descriptor"; +let srcInputDeviceId = 0; try { inputDeviceCooperate.start(sinkDeviceDescriptor, srcInputDeviceId).then(() => { console.log(`Start Keyboard mouse crossing success.`); @@ -215,7 +219,7 @@ stop(): Promise\ | 参数名 | 说明 | | -------- | ---------------------------- | -| Promise\ | Promise对象,异步返回停止键鼠穿越结果。 | +| Promise\ | Promise对象,异步返回停止键鼠穿越结果。 | **示例**: @@ -249,6 +253,7 @@ getState(deviceDescriptor: string, callback: AsyncCallback<{ state: boolean }>): **示例**: ```js +let deviceDescriptor = "descriptor"; try { inputDeviceCooperate.getState(deviceDescriptor, (error, data) => { if (error) { @@ -289,6 +294,7 @@ getState(deviceDescriptor: string): Promise<{ state: boolean }> **示例**: ```js +let deviceDescriptor = "descriptor"; try { inputDeviceCooperate.getState(deviceDescriptor).then((data) => { console.log(`Get the status success, data: ${JSON.stringify(data)}`); @@ -324,7 +330,7 @@ try { inputDeviceCooperate.on('cooperation', (data) => { console.log(`Keyboard mouse crossing event: ${JSON.stringify(data)}`); }); -} catch (err) { +} catch (error) { console.log(`Register failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -350,25 +356,25 @@ off(type: 'cooperation', callback?: AsyncCallback\): void ```js // 取消注册单个回调函数 -callback: function(event) { +function callback(event) { console.log(`Keyboard mouse crossing event: ${JSON.stringify(event)}`); return false; }, try { - inputDeviceCooperate.on('cooperation', this.callback); - inputDeviceCooperate.off("cooperation", this.callback); + inputDeviceCooperate.on('cooperation', callback); + inputDeviceCooperate.off("cooperation", callback); } catch (error) { console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` ```js // 取消注册所有回调函数 -callback: function(event) { +function callback(event) { console.log(`Keyboard mouse crossing event: ${JSON.stringify(event)}`); return false; }, try { - inputDeviceCooperate.on('cooperation', this.callback); + inputDeviceCooperate.on('cooperation', callback); inputDeviceCooperate.off("cooperation"); } catch (error) { console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 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 ecd2d4b1968e32a6ab1c990538bc57c4e898e6f4..6ad7b9bf7af1415ca104854ce87ef89165ba8b92 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @@ -334,19 +334,19 @@ inputDevice.getDeviceInfo(1).then((deviceData) => { ## inputDevice.supportKeys9+ -supportKeys(deviceId: number, keys: Array<KeyCode>, callback: Callback<Array<boolean>>): void +supportKeys(deviceId: number, keys: Array<KeyCode>, callback: AsyncCallback <Array<boolean>>): void -获取输入设备是否支持指定的键码值,使用Callback异步方式返回结果。 +获取输入设备是否支持指定的键码值,使用AsyncCallback异步方式返回结果。 **系统能力**:SystemCapability.MultimodalInput.Input.InputDevice **参数**: -| 参数 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------ | ---- | ------------------------------------------------------ | -| deviceId | number | 是 | 输入设备id,同一个物理设备反复插拔,设备id会发生变化。 | -| keys | Array<KeyCode> | 是 | 需要查询的键码值,最多支持5个按键查询。 | -| callback | Callback<Array<boolean>> | 是 | 回调函数,异步返回查询结果。 | +| 参数 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------- | ---- | ------------------------------------------------------ | +| deviceId | number | 是 | 输入设备id,同一个物理设备反复插拔,设备id会发生变化。 | +| keys | Array<KeyCode> | 是 | 需要查询的键码值,最多支持5个按键查询。 | +| callback | AsyncCallback<Array<boolean>> | 是 | 回调函数,异步返回查询结果。 | **示例**: diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md b/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md index 80d1a26688e276daea5ed1572764368ef93fb8ba..d23d842670d79d7b06a1b1a437ade4482354e299 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md @@ -41,7 +41,7 @@ try { keyDownDuration: 0, isIntercepted: false } - inputEventClient.injectKeyEvent({ KeyEvent: backKeyDown }); + inputEventClient.injectEvent({ KeyEvent: backKeyDown }); let backKeyUp = { isPressed: false, @@ -49,7 +49,7 @@ try { keyDownDuration: 0, isIntercepted: false }; - inputEventClient.injectKeyEvent({ KeyEvent: backKeyUp }); + inputEventClient.injectEvent({ KeyEvent: backKeyUp }); } catch (error) { console.log(`Failed to inject KeyEvent, error: ${JSON.stringify(error, [`code`, `message`])}`); } 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 242b63a32ab5337185af44603502d634ae068b2b..85716542e22921480952629fdc7d034f51f2ee1f 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md @@ -194,7 +194,7 @@ try { ```js try { inputMonitor.on("touch", touchEvent => { - if (touchEvent.touches.size() == 3) { // 当前有三个手指按下 + if (touchEvent.touches.length == 3) { // 当前有三个手指按下 return true; } else { return false;