Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
177547a0
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
177547a0
编写于
9月 06, 2023
作者:
P
PingPing2023
提交者:
Gitee
9月 06, 2023
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update zh-cn/application-dev/reference/apis/js-apis-inputdevice.md.
Signed-off-by:
N
PingPing2023
<
pingping@huawei.com
>
上级
d6467882
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
12 deletion
+12
-12
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
+12
-12
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
浏览文件 @
177547a0
...
...
@@ -34,7 +34,7 @@ getDeviceList(callback: AsyncCallback<Array<number>>): void
```
js
try
{
inputDevice
.
getDeviceList
((
error
,
ids
)
=>
{
inputDevice
.
getDeviceList
((
error
:
Error
,
ids
:
Array
<
number
>
)
=>
{
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
,
d
eviceData
)
=>
{
inputDevice
.
getDevice
(
1
,
(
error
:
Error
,
deviceData
:
inputDevice
.
InputD
eviceData
)
=>
{
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
<
boolean
>
)
=>
{
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
)
{
...
...
Miykael_xxm
🚴
@xiongjiamu
mentioned in commit
5251197b
·
9月 07, 2023
mentioned in commit
5251197b
mentioned in commit 5251197b8a6ccf3b6c955f060d87ac680511311d
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录