diff --git a/zh-cn/application-dev/device/inputdevice-guidelines.md b/zh-cn/application-dev/device/inputdevice-guidelines.md index d08fbacfef9c363dfb8b4c206008b05793e5434e..81a808458a668734146a544c67e871913a0a8934 100644 --- a/zh-cn/application-dev/device/inputdevice-guidelines.md +++ b/zh-cn/application-dev/device/inputdevice-guidelines.md @@ -16,8 +16,8 @@ import inputDevice from '@ohos.multimodalInput.inputDevice'; | 实例名 | 接口名 | 说明 | | ----------- | ------------------------------------------------------------ | -------------------------- | -| inputDevice | function getDeviceList(callback: AsyncCallback\>): void; | 获取输入设备列表。 | -| inputDevice | function getKeyboardType(deviceId: number, callback: AsyncCallback\): void; | 获取输入设备的键盘类型。 | +| inputDevice | function getDeviceList(): Promise\>; | 获取输入设备列表。 | +| inputDevice | function getKeyboardType(deviceId: number): Promise\; | 获取输入设备的键盘类型。 | | inputDevice | function on(type: "change", listener: Callback\): void; | 监听输入设备的热插拔事件。 | | inputDevice | function off(type: "change", listener?: Callback\): void; | 取消监听输入设备的热插拔事件。 | @@ -51,7 +51,7 @@ try { // 2.监听设备热插拔 inputDevice.on("change", (data) => { console.log(`Device event info: ${JSON.stringify(data)}`); - inputDevice.getKeyboardType(data.deviceId, (error, type) => { + inputDevice.getKeyboardType(data.deviceId).then((type) => { console.log("The keyboard type is: " + type); if (type === inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') { // 物理键盘已插入 diff --git a/zh-cn/application-dev/reference/apis/js-apis-pointer.md b/zh-cn/application-dev/reference/apis/js-apis-pointer.md index cb8bab502a388bba94fceba5a648cbb8788cc842..014b704990f690340b4f2a9c206cc08abeb07cb7 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-pointer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-pointer.md @@ -122,9 +122,13 @@ isPointerVisible(): Promise<boolean> **示例**: ```js -pointer.isPointerVisible().then((visible) => { - console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`); -}); +try { + pointer.isPointerVisible().then((visible) => { + console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`); + }); +} catch (error) { + console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} ``` ## pointer.setPointerSpeed9+