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 9d72afe1700b522d9b1eff7f3ddecc25adf79dd8..eaad81311b59843b2867357ab5b3efbdc94abb61 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @@ -34,7 +34,7 @@ getDeviceList(callback: AsyncCallback<Array<number>>): void ```js try { - inputDevice.getDeviceList((error, ids) => { + inputDevice.getDeviceList((error: Error, ids: Array) => { if (error) { console.log(`Failed to get device id list, error: ${JSON.stringify(error, [`code`, `message`])}`); return; @@ -129,7 +129,7 @@ getDeviceInfo(deviceId: number): Promise<InputDeviceData> ```js // 获取输入设备id为1的设备信息。 try { - inputDevice.getDeviceInfo(1).then((deviceData) => { + inputDevice.getDeviceInfo(1).then((deviceData: inputDevice.InputDeviceData) => { console.log(`Device info: ${JSON.stringify(deviceData)}`); }); } catch (error) { @@ -194,7 +194,7 @@ off(type: "change", listener?: Callback<DeviceListener>): void **示例**: ```js -function callback(data) { +function callback(data: inputDevice.DeviceListener) { console.log(`Report device event info: ${JSON.stringify(data, [`type`, `deviceId`])}`); }; @@ -292,7 +292,7 @@ getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): voi ```js // 获取输入设备id为1的设备信息。 -inputDevice.getDevice(1, (error, deviceData) => { +inputDevice.getDevice(1, (error: Error, deviceData: inputDevice.InputDeviceData) => { if (error) { console.log(`Failed to get device info, error: ${JSON.stringify(error, [`code`, `message`])}`); return; @@ -327,7 +327,7 @@ getDevice(deviceId: number): Promise<InputDeviceData> ```js // 获取输入设备id为1的设备信息。 -inputDevice.getDevice(1).then((deviceData) => { +inputDevice.getDevice(1).then((deviceData: inputDevice.InputDeviceData) => { console.log(`Device info: ${JSON.stringify(deviceData)}`); }); ``` @@ -387,7 +387,7 @@ supportKeys(deviceId: number, keys: Array<KeyCode>): Promise<Array<b ```js // 查询id为1的输入设备对于17、22和2055按键的支持情况。 try { - inputDevice.supportKeys(1, [17, 22, 2055]).then((supportResult) => { + inputDevice.supportKeys(1, [17, 22, 2055]).then((supportResult: Array) => { console.log(`Query result: ${JSON.stringify(supportResult)}`); }); } catch (error) { @@ -415,7 +415,7 @@ getKeyboardType(deviceId: number, callback: AsyncCallback<KeyboardType>): ```js // 查询id为1的输入设备的键盘类型。 try { - inputDevice.getKeyboardType(1, (error, type) => { + inputDevice.getKeyboardType(1, (error: Error, type: number) => { if (error) { console.log(`Failed to get keyboard type, error: ${JSON.stringify(error, [`code`, `message`])}`); return; @@ -481,7 +481,7 @@ setKeyboardRepeatDelay(delay: number, callback: AsyncCallback<void>): void ```js try { - inputDevice.setKeyboardRepeatDelay(350, (error) => { + inputDevice.setKeyboardRepeatDelay(350, (error: Error) => { if (error) { console.log(`Set keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`); return; @@ -579,7 +579,7 @@ getKeyboardRepeatDelay(): Promise<number> ```js try { - inputDevice.getKeyboardRepeatDelay().then(delay => { + inputDevice.getKeyboardRepeatDelay().then((delay: number) => { console.log(`Get keyboard repeat delay success`); }); } catch (error) { @@ -608,7 +608,7 @@ setKeyboardRepeatRate(rate: number, callback: AsyncCallback<void>): void ```js try { - inputDevice.setKeyboardRepeatRate(60, (error) => { + inputDevice.setKeyboardRepeatRate(60, (error: Error) => { if (error) { console.log(`Set keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); return; @@ -674,7 +674,7 @@ getKeyboardRepeatRate(callback: AsyncCallback<number>): void ```js try { - inputDevice.getKeyboardRepeatRate((error, rate) => { + inputDevice.getKeyboardRepeatRate((error: Error, rate: number) => { if (error) { console.log(`Get keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); return; @@ -706,7 +706,7 @@ getKeyboardRepeatRate(): Promise<number> ```js try { - inputDevice.getKeyboardRepeatRate().then(rate => { + inputDevice.getKeyboardRepeatRate().then((rate: number) => { console.log(`Get keyboard repeat rate success`); }); } catch (error) {