未验证 提交 f69786bc 编写于 作者: O openharmony_ci 提交者: Gitee

!4687 多模接口示例修改

Merge pull request !4687 from mayunteng/myt
...@@ -33,11 +33,11 @@ on(type: “change”, listener: Callback<DeviceListener>): void ...@@ -33,11 +33,11 @@ on(type: “change”, listener: Callback<DeviceListener>): void
**示例:** **示例:**
```js ```js
let isPhysicalKeyboardExist = false; let isPhysicalKeyboardExist = true;
inputDevice.on("change", (data)=>{ inputDevice.on("change", (data) => {
console.log("type: " + data.type + ", deviceId: " + data.deviceId); console.log("type: " + data.type + ", deviceId: " + data.deviceId);
inputDevice.getKeyboardType(data.deviceId, (ret) => { inputDevice.getKeyboardType(data.deviceId, (ret) => {
console.log("The keyboard type of the device is: " + ret); console.log("The keyboard type of the device is: " + ret);
if (ret == 2 && data.type == 'add') { if (ret == 2 && data.type == 'add') {
// 监听物理键盘已连接。 // 监听物理键盘已连接。
isPhysicalKeyboardExist = true; isPhysicalKeyboardExist = true;
...@@ -77,6 +77,7 @@ inputDevice.off("change", this.listener); ...@@ -77,6 +77,7 @@ inputDevice.off("change", this.listener);
// 取消所有监听 // 取消所有监听
inputDevice.off("change"); inputDevice.off("change");
// 取消监听后,软键盘默认都弹出
``` ```
## inputDevice.getDeviceIds ## inputDevice.getDeviceIds
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册