Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
ccd023ff
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
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看板
提交
ccd023ff
编写于
6月 29, 2022
作者:
S
shaoziyun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
多模md文件修改
Signed-off-by:
N
shaoziyun
<
shaoziyun@huawei.com
>
上级
b0216230
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
132 addition
and
165 deletion
+132
-165
zh-cn/application-dev/reference/apis/Readme-CN.md
zh-cn/application-dev/reference/apis/Readme-CN.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md
...n/application-dev/reference/apis/js-apis-inputconsumer.md
+17
-12
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
+87
-88
zh-cn/application-dev/reference/apis/js-apis-inputevent.md
zh-cn/application-dev/reference/apis/js-apis-inputevent.md
+3
-1
zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md
...pplication-dev/reference/apis/js-apis-inputeventclient.md
+8
-3
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md
+12
-58
zh-cn/application-dev/reference/apis/js-apis-keycode.md
zh-cn/application-dev/reference/apis/js-apis-keycode.md
+3
-1
zh-cn/application-dev/reference/apis/js-apis-keyevent.md
zh-cn/application-dev/reference/apis/js-apis-keyevent.md
+1
-1
未找到文件。
zh-cn/application-dev/reference/apis/Readme-CN.md
浏览文件 @
ccd023ff
...
@@ -182,7 +182,7 @@
...
@@ -182,7 +182,7 @@
-
[
@ohos.multimodalInput.keyCode (键值)
](
js-apis-keycode.md
)
-
[
@ohos.multimodalInput.keyCode (键值)
](
js-apis-keycode.md
)
-
[
@ohos.multimodalInput.keyEvent (按键输入事件)
](
js-apis-keyevent.md
)
-
[
@ohos.multimodalInput.keyEvent (按键输入事件)
](
js-apis-keyevent.md
)
-
[
@ohos.multimodalInput.mouseEvent (鼠标输入事件)
](
js-apis-mouseevent.md
)
-
[
@ohos.multimodalInput.mouseEvent (鼠标输入事件)
](
js-apis-mouseevent.md
)
-
[
@ohos.multimodalInput.
Touc
Event (触摸输入事件)
](
js-apis-touchevent.md
)
-
[
@ohos.multimodalInput.
touch
Event (触摸输入事件)
](
js-apis-touchevent.md
)
-
[
@ohos.power (系统电源管理)
](
js-apis-power.md
)
-
[
@ohos.power (系统电源管理)
](
js-apis-power.md
)
-
[
@ohos.runningLock (Runninglock锁)
](
js-apis-runninglock.md
)
-
[
@ohos.runningLock (Runninglock锁)
](
js-apis-runninglock.md
)
-
[
@ohos.sensor (传感器)
](
js-apis-sensor.md
)
-
[
@ohos.sensor (传感器)
](
js-apis-sensor.md
)
...
...
zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md
浏览文件 @
ccd023ff
# 组合按键
# 组合按键
InputConsumer模块提供对按键事件的监听。
>  **说明:**
>  **说明:**
>
>
...
@@ -18,19 +19,19 @@ import inputConsumer from '@ohos.multimodalInput.inputConsumer';
...
@@ -18,19 +19,19 @@ import inputConsumer from '@ohos.multimodalInput.inputConsumer';
## inputConsumer.on
## inputConsumer.on
on(type: "key", keyOptions: KeyOptions, callback: Callback
<KeyOptions>
): void
on(type: "key", keyOptions: KeyOptions, callback: Callback
<
KeyOptions
>
): void
开始监听组合按键事件, 当满足条件的组合按键输入事件发生时,将keyOptions回调到入参callback表示的回调函数上。
开始监听组合按键事件, 当满足条件的组合按键输入事件发生时,将keyOptions回调到入参callback表示的回调函数上。
**系统能力:**
SystemCapability.MultimodalInput.Input.InputConsumer
此接口为系统接口。
**参数:**
**参数:**
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 监听输入事件类型,只支持“key”。 |
| type | string | 是 | 监听输入事件类型,只支持“key”。 |
| keyOptions |
[
keyOptions
](
#keyOptions
)
| 是 | 组合键选项,用来指定组合键输入时应该符合的条件。 |
| keyOptions |
[
keyOptions
](
#keyOptions
)
| 是 | 组合键选项,用来指定组合键输入时应该符合的条件。 |
| callback |
KeyOptions | 是 | 回调函数。当满足条件的按键输入产生时,回调到此函数,以传入的KeyOptions为入参。 |
| callback |
Callback
<
KeyOptions
>
| 是 | 回调函数。当满足条件的按键输入产生时,回调到此函数,以传入的KeyOptions为入参。 |
**示例:**
**示例:**
...
@@ -46,19 +47,21 @@ inputConsumer.on('key', keyOptions, callback);
...
@@ -46,19 +47,21 @@ inputConsumer.on('key', keyOptions, callback);
## inputConsumer.off
## inputConsumer.off
off(type: "key", keyOptions: KeyOptions, callback?: Callback
<KeyOptions>
): void
off(type: "key", keyOptions: KeyOptions, callback?: Callback
<
KeyOptions
>
): void
停止监听组合按键事件。
停止监听组合按键事件。
此接口为系统接口。
**系统能力:**
SystemCapability.MultimodalInput.Input.InputConsumer
**系统能力:**
SystemCapability.MultimodalInput.Input.InputConsumer
**参数:**
**参数:**
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 监听输入事件类型,只支持“key”。 |
| type | string | 是 | 监听输入事件类型,只支持“key”。 |
| keyOptions |
[
keyOptions
](
#keyOptions
)
| 是 | 开始监听时传入的keyOptions。 |
| keyOptions |
[
keyOptions
](
#keyOptions
)
| 是 | 开始监听时传入的keyOptions。 |
| callback | Callback
<KeyOptions>
| 是 | 开始监听时与KeyOption一同传入的回调函数
。 |
| callback | Callback
<
KeyOptions
>
| 是 | 开始监听时与KeyOption一同传入的回调函数
。 |
**示例:**
**示例:**
...
@@ -76,7 +79,9 @@ inputConsumer.off('key', keyOptions, callback);
...
@@ -76,7 +79,9 @@ inputConsumer.off('key', keyOptions, callback);
组合键输入事件发生时,组合键满足的选项。
组合键输入事件发生时,组合键满足的选项。
**系统能力:**
以下各项对应系统能力均为SystemCapability.MultimodalInput.Input.InputConsumer
此接口为系统接口。
**系统能力:**
SystemCapability.MultimodalInput.Input.InputConsumer
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
...
...
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
浏览文件 @
ccd023ff
...
@@ -4,8 +4,7 @@
...
@@ -4,8 +4,7 @@
输入设备管理模块,用于监听输入设备连接、断开和变化,并查看输入设备相关信息。比如监听鼠标插拔,并获取鼠标的id、name和指针移动速度等信息。
输入设备管理模块,用于监听输入设备连接、断开和变化,并查看输入设备相关信息。比如监听鼠标插拔,并获取鼠标的id、name和指针移动速度等信息。
> **说明:**
> **说明**:<br>
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...
@@ -20,33 +19,33 @@ import inputDevice from '@ohos.multimodalInput.inputDevice';
...
@@ -20,33 +19,33 @@ import inputDevice from '@ohos.multimodalInput.inputDevice';
on(type: “change”, listener: Callback
<
DeviceListener
>
): void
on(type: “change”, listener: Callback
<
DeviceListener
>
): void
监听设备的热插拔事件。
监听
输入
设备的热插拔事件。
**系统能力
:**
SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
SystemCapability.MultimodalInput.Input.InputDevice
**参数
:**
**参数
**
:
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明
|
| -------- | ---------------------------------------- | ---- | ---------- |
| -------- | ---------------------------------------- | ---- | ----------
-
|
| type | string | 是 | 输入设备的事件类型 |
| type | string | 是 | 输入设备的事件类型
。
|
| listener | Callback
<
[DeviceListener](#devicelistener
)
>
| 是 | 可上报的输入设备事件
|
| listener | Callback
<
[DeviceListener](#devicelistener
<sup>
9+
</sup>
)
>
| 是 | 可上报的输入设备事件。
|
**示例
:**
**示例
**
:
```
js
```
js
let
isPhysicalKeyboardExist
=
true
;
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
,
(
err
,
ret
)
=>
{
console
.
log
(
"
The keyboard type of the device is:
"
+
ret
);
console
.
log
(
"
The keyboard type of the device is:
"
+
ret
);
if
(
ret
==
inputDevice
.
KeyboardType
.
ALPHABETIC_KEYBOARD
&&
data
.
type
==
'
add
'
)
{
if
(
ret
==
inputDevice
.
KeyboardType
.
ALPHABETIC_KEYBOARD
&&
data
.
type
==
'
add
'
)
{
// 监听物理键盘已连接。
// 监听物理键盘已连接。
isPhysicalKeyboardExist
=
true
;
isPhysicalKeyboardExist
=
true
;
}
else
if
(
ret
==
inputDevice
.
KeyboardType
.
ALPHABETIC_KEYBOARD
&&
data
.
type
==
'
remove
'
)
{
}
else
if
(
ret
==
inputDevice
.
KeyboardType
.
ALPHABETIC_KEYBOARD
&&
data
.
type
==
'
remove
'
)
{
// 监听物理键盘已断开。
// 监听物理键盘已断开。
isPhysicalKeyboardExist
=
false
;
isPhysicalKeyboardExist
=
false
;
}
}
});
});
});
});
// 根据isPhysicalKeyboardExist的值决定软键盘是否弹出。
// 根据isPhysicalKeyboardExist的值决定软键盘是否弹出。
```
```
...
@@ -55,30 +54,30 @@ inputDevice.on("change", (data) => {
...
@@ -55,30 +54,30 @@ inputDevice.on("change", (data) => {
off(type: “change”, listener?: Callback
<
DeviceListener
>
): void
off(type: “change”, listener?: Callback
<
DeviceListener
>
): void
取消监听设备的热插拔事件。
取消监听
输入
设备的热插拔事件。
**系统能力
:**
SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
SystemCapability.MultimodalInput.Input.InputDevice
**参数
:**
**参数
**
:
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明
|
| -------- | ---------------------------------------- | ---- | ---------- |
| -------- | ---------------------------------------- | ---- | ----------
-
|
| type | string | 是 | 输入设备的事件类型 |
| type | string | 是 | 输入设备的事件类型
。
|
| listener | Callback
<
[DeviceListener](#devicelistener
)
>
| 否 | 可上报的输入设备事件
|
| listener | Callback
<
[DeviceListener](#devicelistener
<sup>
9+
</sup>
)
>
| 否 | 可上报的输入设备事件。
|
**示例
:**
**示例
**
:
```
js
```
js
function
listener
(
data
)
{
function
listener
(
data
)
{
console
.
log
(
"
type:
"
+
data
.
type
+
"
, deviceId:
"
+
data
.
deviceId
);
console
.
log
(
"
type:
"
+
data
.
type
+
"
, deviceId:
"
+
data
.
deviceId
);
}
}
// 单独取消listener的监听。
// 单独取消listener的监听。
inputDevice
.
off
(
"
change
"
,
listener
);
inputDevice
.
off
(
"
change
"
,
listener
);
// 取消所有监听
// 取消所有监听
。
inputDevice
.
off
(
"
change
"
);
inputDevice
.
off
(
"
change
"
);
// 取消监听后,软键盘默认都弹出
// 取消监听后,软键盘默认都弹出
。
```
```
## inputDevice.getDeviceIds
## inputDevice.getDeviceIds
...
@@ -87,15 +86,15 @@ getDeviceIds(callback: AsyncCallback<Array<number>>): void
...
@@ -87,15 +86,15 @@ getDeviceIds(callback: AsyncCallback<Array<number>>): void
获取所有输入设备的id列表,使用callback方式作为异步方法。
获取所有输入设备的id列表,使用callback方式作为异步方法。
**系统能力
:**
SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
SystemCapability.MultimodalInput.Input.InputDevice
**参数
:**
**参数
**
:
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ----- |
| -------- | ---------------------------------------- | ---- | ----- |
| callback | AsyncCallback
<
Array
<
number
>>
| 是 | 回调函数。 |
| callback | AsyncCallback
<
Array
<
number
>>
| 是 | 回调函数。 |
**示例
:**
**示例
**
:
```
js
```
js
inputDevice
.
getDeviceIds
((
ids
)
=>
{
inputDevice
.
getDeviceIds
((
ids
)
=>
{
...
@@ -105,19 +104,19 @@ inputDevice.getDeviceIds((ids)=>{
...
@@ -105,19 +104,19 @@ inputDevice.getDeviceIds((ids)=>{
## inputDevice.getDeviceIds
## inputDevice.getDeviceIds
function getDeviceIds(): Promise
<
<
Array
<
number
>>
getDeviceIds(): Promise
<
Array
<
number
>>
获取所有输入设备的id列表,使用Promise方式作为异步方法。
获取所有输入设备的id列表,使用Promise方式作为异步方法。
**系统能力
:**
SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
SystemCapability.MultimodalInput.Input.InputDevice
**返回值
:**
**返回值
**
:
| 参数 | 说明 |
| 参数 | 说明
|
| ---------------------------------- | ------------------ |
| ---------------------------------- | ------------------
-
|
| Promise
<
Array
<
number
>>
| Promise实例,用于异步获取结果 |
| Promise
<
Array
<
number
>>
| Promise实例,用于异步获取结果
。
|
**示例
:**
**示例
**
:
```
js
```
js
inputDevice
.
getDeviceIds
().
then
((
ids
)
=>
{
inputDevice
.
getDeviceIds
().
then
((
ids
)
=>
{
...
@@ -131,16 +130,16 @@ getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): voi
...
@@ -131,16 +130,16 @@ getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): voi
获取输入设备的描述信息,使用callback方式作为异步方法。
获取输入设备的描述信息,使用callback方式作为异步方法。
**系统能力
:**
SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
SystemCapability.MultimodalInput.Input.InputDevice
**参数
:**
**参数
**
:
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | --------------------------- |
| -------- | ---------------------------------------- | ---- | --------------------------- |
| deviceId | number | 是 | 需要获取信息的设备id。 |
| deviceId | number | 是 | 需要获取信息的设备id。 |
| callback | AsyncCallback
<
[InputDeviceData](#inputdevicedata)
>
| 是 | 回调函数,异步返回InputDeviceData对象。 |
| callback | AsyncCallback
<
[InputDeviceData](#inputdevicedata)
>
| 是 | 回调函数,异步返回InputDeviceData对象。 |
**示例
:**
**示例
**
:
```
js
```
js
// 示例获取设备id为1的设备name信息。
// 示例获取设备id为1的设备name信息。
...
@@ -151,25 +150,25 @@ inputDevice.getDevice(1, (inputDevice)=>{
...
@@ -151,25 +150,25 @@ inputDevice.getDevice(1, (inputDevice)=>{
## inputDevice.getDevice
## inputDevice.getDevice
function
getDevice(deviceId: number): Promise
<
InputDeviceData
>
getDevice(deviceId: number): Promise
<
InputDeviceData
>
获取输入设备的描述信息,使用Promise方式作为异步方法。
获取输入设备的描述信息,使用Promise方式作为异步方法。
**系统能力
:**
SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
SystemCapability.MultimodalInput.Input.InputDevice
**参数
:**
**参数
**
:
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------ |
| -------- | ------ | ---- | ------------ |
| deviceId | number | 是 | 需要获取信息的设备id。 |
| deviceId | number | 是 | 需要获取信息的设备id。 |
**返回值
:**
**返回值
**
:
| 参数 | 说明 |
| 参数 | 说明
|
| ---------------------------------------- | ------------------ |
| ---------------------------------------- | ------------------
-
|
| Promise
<
[InputDeviceData](#inputdevicedata)
>
| Promise实例,用于异步获取结果 |
| Promise
<
[InputDeviceData](#inputdevicedata)
>
| Promise实例,用于异步获取结果
。
|
**示例
:**
**示例
**
:
```
js
```
js
// 示例获取设备id为1的设备name信息。
// 示例获取设备id为1的设备name信息。
...
@@ -180,13 +179,13 @@ inputDevice.getDevice(1).then((inputDevice)=>{
...
@@ -180,13 +179,13 @@ inputDevice.getDevice(1).then((inputDevice)=>{
## inputDevice.supportKeys<sup>9+</sup>
## inputDevice.supportKeys<sup>9+</sup>
supportKeys(deviceId: number, keys: Array
<
KeyCode
>
, callback: Callback
<
Array
<
boolean
>>
): void
;
supportKeys(deviceId: number, keys: Array
<
KeyCode
>
, callback: Callback
<
Array
<
boolean
>>
): void
获取输入设备
的描述信息
,使用callback方式作为异步方法。
获取输入设备
支持的键码值
,使用callback方式作为异步方法。
**系统能力
:**
SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
SystemCapability.MultimodalInput.Input.InputDevice
**参数
:**
**参数
**
:
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | --------------------------------- |
| -------- | ------------------------------------ | ---- | --------------------------------- |
...
@@ -194,7 +193,7 @@ supportKeys(deviceId: number, keys: Array<KeyCode>, callback: Callback<
...
@@ -194,7 +193,7 @@ supportKeys(deviceId: number, keys: Array<KeyCode>, callback: Callback<
| keys | Array
<
KeyCode
>
| 是 | 需要查询的键码值,最多支持5个按键查询。 |
| keys | Array
<
KeyCode
>
| 是 | 需要查询的键码值,最多支持5个按键查询。 |
| callback | Callback
<
Array
<
boolean
>>
| 是 | 回调函数,异步返回查询结果。 |
| callback | Callback
<
Array
<
boolean
>>
| 是 | 回调函数,异步返回查询结果。 |
**示例
:**
**示例
**
:
```
js
```
js
// 示例查询id为1的设备对于17、22和2055按键的支持情况。
// 示例查询id为1的设备对于17、22和2055按键的支持情况。
...
@@ -205,26 +204,26 @@ inputDevice.supportKeys(1, [17, 22, 2055], (ret)=>{
...
@@ -205,26 +204,26 @@ inputDevice.supportKeys(1, [17, 22, 2055], (ret)=>{
## inputDevice.supportKeys<sup>9+</sup>
## inputDevice.supportKeys<sup>9+</sup>
supportKeys(deviceId: number, keys: Array
<
KeyCode
>
): Promise
<
Array
<
boolean
>>
;
supportKeys(deviceId: number, keys: Array
<
KeyCode
>
): Promise
<
Array
<
boolean
>>
获取输入设备
的描述信息
,使用Promise方式作为异步方法。
获取输入设备
支持的键码值
,使用Promise方式作为异步方法。
**系统能力
:**
SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
SystemCapability.MultimodalInput.Input.InputDevice
**参数
:**
**参数
**
:
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | --------------------------------- |
| -------- | -------------------- | ---- | --------------------------------- |
| deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| keys | Array
<
KeyCode
>
| 是 | 需要查询的键码值,最多支持5个按键查询。 |
| keys | Array
<
KeyCode
>
| 是 | 需要查询的键码值,最多支持5个按键查询。 |
**返回值
:**
**返回值
**
:
| 参数 | 说明 |
| 参数 | 说明
|
| ----------------------------------- | ------------------ |
| ----------------------------------- | ------------------
-
|
| Promise
<
Array
<
boolean
>>
| Promise实例,用于异步获取结果 |
| Promise
<
Array
<
boolean
>>
| Promise实例,用于异步获取结果
。
|
**示例
:**
**示例
**
:
```
js
```
js
// 示例查询id为1的设备对于17、22和2055按键的支持情况。
// 示例查询id为1的设备对于17、22和2055按键的支持情况。
...
@@ -235,20 +234,20 @@ inputDevice.supportKeys(1, [17, 22, 2055]).then((ret)=>{
...
@@ -235,20 +234,20 @@ inputDevice.supportKeys(1, [17, 22, 2055]).then((ret)=>{
## inputDevice.getKeyboardType<sup>9+</sup>
## inputDevice.getKeyboardType<sup>9+</sup>
getKeyboardType(deviceId: number, callback: AsyncCallback
<
KeyboardType
>
): void
;
getKeyboardType(deviceId: number, callback: AsyncCallback
<
KeyboardType
>
): void
查询输入设备的键盘类型,使用callback方式作为异步方法。
查询输入设备的键盘类型,使用callback方式作为异步方法。
**系统能力
:**
SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
SystemCapability.MultimodalInput.Input.InputDevice
**参数
:**
**参数
**
:
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | --------------------------------- |
| -------- | ---------------------------------------- | ---- | --------------------------------- |
| deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| callback | AsyncCallback
<
[KeyboardType](#keyboardtype)
>
| 是 | 回调函数,异步返回查询结果。 |
| callback | AsyncCallback
<
[KeyboardType](#keyboardtype)
>
| 是 | 回调函数,异步返回查询结果。 |
**示例
:**
**示例
**
:
```
js
```
js
// 示例查询设备id为1的设备键盘类型。
// 示例查询设备id为1的设备键盘类型。
...
@@ -259,19 +258,19 @@ inputDevice.getKeyboardType(1, (ret)=>{
...
@@ -259,19 +258,19 @@ inputDevice.getKeyboardType(1, (ret)=>{
## inputDevice.getKeyboardType<sup>9+</sup>
## inputDevice.getKeyboardType<sup>9+</sup>
getKeyboardType(deviceId: number
,): Promise
<
KeyboardType
>
;
getKeyboardType(deviceId: number
): Promise
<
KeyboardType
>
查询输入设备的键盘类型,使用Promise方式作为异步方法。
查询输入设备的键盘类型,使用Promise方式作为异步方法。
**系统能力
:**
SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
SystemCapability.MultimodalInput.Input.InputDevice
**返回值
:**
**返回值
**
:
| 参数 | 说明 |
| 参数 | 说明
|
| ---------------------------------------- | ------------------ |
| ---------------------------------------- | ------------------
-
|
| Promise
<
[KeyboardType](#keyboardtype)
>
| Promise实例,用于异步获取结果 |
| Promise
<
[KeyboardType](#keyboardtype)
>
| Promise实例,用于异步获取结果
。
|
**示例
:**
**示例
**
:
```
js
```
js
// 示例查询设备id为1的设备键盘类型。
// 示例查询设备id为1的设备键盘类型。
...
@@ -284,7 +283,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{
...
@@ -284,7 +283,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{
输入设备的描述信息。
输入设备的描述信息。
**系统能力
:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| 名称 | 参数类型 | 说明 |
| -------- | --------------------------- | --------------------------------- |
| -------- | --------------------------- | --------------------------------- |
...
@@ -295,7 +294,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{
...
@@ -295,7 +294,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{
输入设备的描述信息。
输入设备的描述信息。
**系统能力
:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| 名称 | 参数类型 | 说明 |
| -------------------- | -------------------------------------- | ---------------------------------------- |
| -------------------- | -------------------------------------- | ---------------------------------------- |
...
@@ -312,9 +311,9 @@ inputDevice.getKeyboardType(1).then((ret)=>{
...
@@ -312,9 +311,9 @@ inputDevice.getKeyboardType(1).then((ret)=>{
## AxisType<sup>9+</sup>
## AxisType<sup>9+</sup>
输入设备的轴类型
输入设备的轴类型
。
**系统能力
:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| 名称 | 参数类型 | 说明 |
| ----------- | ------ | --------------- |
| ----------- | ------ | --------------- |
...
@@ -330,14 +329,14 @@ inputDevice.getKeyboardType(1).then((ret)=>{
...
@@ -330,14 +329,14 @@ inputDevice.getKeyboardType(1).then((ret)=>{
## AxisRange
## AxisRange
输入设备的轴信息
输入设备的轴信息
。
**系统能力
:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| 名称 | 参数类型 | 说明 |
| ----------------------- | ------------------------- | -------- |
| ----------------------- | ------------------------- | -------- |
| source |
[
SourceType
](
#sourcetype
)
| 轴的输入源类型。 |
| source |
[
SourceType
](
#sourcetype
)
| 轴的输入源类型。 |
| axis |
[
AxisType
](
axistype
)
| 轴的类型。 |
| axis |
[
AxisType
](
#axistype
)
| 轴的类型。 |
| max | number | 轴的最大值。 |
| max | number | 轴的最大值。 |
| min | number | 轴的最小值。 |
| min | number | 轴的最小值。 |
| fuzz
<sup>
9+
</sup>
| number | 轴的模糊值。 |
| fuzz
<sup>
9+
</sup>
| number | 轴的模糊值。 |
...
@@ -348,7 +347,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{
...
@@ -348,7 +347,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{
定义这个轴的输入源类型。比如鼠标设备可上报x轴事件,则x轴的源就是鼠标。
定义这个轴的输入源类型。比如鼠标设备可上报x轴事件,则x轴的源就是鼠标。
**系统能力
:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| 名称 | 参数类型 | 说明 |
| ----------- | ------ | ----------- |
| ----------- | ------ | ----------- |
...
@@ -363,7 +362,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{
...
@@ -363,7 +362,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{
定义监听设备热插拔事件。
定义监听设备热插拔事件。
**系统能力
:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| 名称 | 参数类型 | 说明 |
| ------ | ------ | --------- |
| ------ | ------ | --------- |
...
@@ -374,7 +373,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{
...
@@ -374,7 +373,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{
定义键盘输入设备的类型。
定义键盘输入设备的类型。
**系统能力
:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
**系统能力
**
:
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 值 | 说明 |
| 名称 | 参数类型 | 值 | 说明 |
| ------------------- | ------ | ---- | --------- |
| ------------------- | ------ | ---- | --------- |
...
...
zh-cn/application-dev/reference/apis/js-apis-inputevent.md
浏览文件 @
ccd023ff
# 输入事件
# 输入事件
设备上报的基本事件。
InputEvent模块描述了
设备上报的基本事件。
>  **说明:**
>  **说明:**
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...
@@ -11,6 +11,8 @@
...
@@ -11,6 +11,8 @@
import
InputEvent
from
'
@ohos.multimodalInput.inputEvent
'
;
import
InputEvent
from
'
@ohos.multimodalInput.inputEvent
'
;
```
```
## InputEvent
**系统能力**
:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.Core
**系统能力**
:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.Core
| 名称 | 参数类型 | 可读 | 可写 | 描述 |
| 名称 | 参数类型 | 可读 | 可写 | 描述 |
...
...
zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md
100644 → 100755
浏览文件 @
ccd023ff
# 注入按键
# 注入按键
InputEventClient模块提供了注入按键能力。
> **说明:**
> **说明:**
>
>
...
@@ -22,6 +23,8 @@ injectEvent({KeyEvent: KeyEvent}): void
...
@@ -22,6 +23,8 @@ injectEvent({KeyEvent: KeyEvent}): void
注入按键,KeyEvent为注入按键的描述信息。
注入按键,KeyEvent为注入按键的描述信息。
此接口为系统接口。
**系统能力:**
SystemCapability.MultimodalInput.Input.InputSimulator
**系统能力:**
SystemCapability.MultimodalInput.Input.InputSimulator
**参数:**
**参数:**
...
@@ -47,11 +50,13 @@ let res = inputEventClient.injectEvent({KeyEvent: keyEvent});
...
@@ -47,11 +50,13 @@ let res = inputEventClient.injectEvent({KeyEvent: keyEvent});
注入按键的描述信息
注入按键的描述信息
此接口为系统接口。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputSimulator
**系统能力:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputSimulator
| 参数 | 类型 | 必填 | 说明 |
| 参数 | 类型 | 必填 | 说明 |
| --------------- | ------- | ---- | --------- |
| --------------- | ------- | ---- | --------- |
| isPressed | boolean | 是 | 按键是否按下 |
| isPressed | boolean | 是 | 按键是否按下 |
| keyCode |
N
umber | 是 | 按键键值 |
| keyCode |
n
umber | 是 | 按键键值 |
| keyDownDuration |
boolean
| 是 | 按键按下持续时间 |
| keyDownDuration |
number
| 是 | 按键按下持续时间 |
| isIntercepted |
Number
| 是 | 按键是否可以被拦截 |
| isIntercepted |
boolean
| 是 | 按键是否可以被拦截 |
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md
浏览文件 @
ccd023ff
# 输入监听
# 输入监听
InputMonitor模块提供了监听全局触摸事件的功能。
>  **说明:**
>  **说明:**
> - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...
@@ -26,6 +27,8 @@ on(type: "touch", receiver: TouchEventReceiver): void
...
@@ -26,6 +27,8 @@ on(type: "touch", receiver: TouchEventReceiver): void
开始监听全局触屏事件。
开始监听全局触屏事件。
此接口为系统接口。
**需要权限:**
ohos.permission.INPUT_MONITORING
**需要权限:**
ohos.permission.INPUT_MONITORING
**系统能力:**
SystemCapability.MultimodalInput.Input.InputMonitor
**系统能力:**
SystemCapability.MultimodalInput.Input.InputMonitor
...
@@ -45,36 +48,13 @@ inputMonitor.off("touch", (event) => {
...
@@ -45,36 +48,13 @@ inputMonitor.off("touch", (event) => {
});
});
```
```
on(type: "mouse", receiver: TouchEventReceiver): void
开始监听全局鼠标事件。
**需要权限:**
ohos.permission.INPUT_MONITORING
**系统能力:**
SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------- |
| type | string | 是 | 监听输入事件类型,取值“mouse”。 |
| receiver | Callback
<MouseEvent>
| 是 | 鼠标输入事件回调函数。 |
**示例:**
```
js
inputMonitor
.
off
(
"
mouse
"
,
(
event
)
=>
{
// 消费鼠标事件
});
```
## inputMonitor.off
## inputMonitor.off
off(type: "touch", receiver: TouchEventReceiver): void
off(type: "touch", receiver
?
: TouchEventReceiver): void
开始监听全局触屏事件。
停止监听全局触屏事件。
此接口为系统接口。
**需要权限:**
ohos.permission.INPUT_MONITORING
**需要权限:**
ohos.permission.INPUT_MONITORING
...
@@ -92,37 +72,11 @@ off(type: "touch", receiver: TouchEventReceiver): void
...
@@ -92,37 +72,11 @@ off(type: "touch", receiver: TouchEventReceiver): void
inputMonitor
.
off
(
"
touch
"
);
inputMonitor
.
off
(
"
touch
"
);
```
```
off(type: "mouse", receiver?: Callback
<MouseEvent>
): void
停止监听全局鼠标事件。
**需要权限:**
ohos.permission.INPUT_MONITORING
**系统能力:**
SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------- |
| type | string | 是 | 监听输入事件类型,取值“mouse”。 |
| receiver | Callback
<MouseEvent>
| 否 | 鼠标输入事件回调函数。 |
**示例:**
```
js
inputMonitor
.
off
(
"
mouse
"
);
```
## TouchEventReceiver
## TouchEventReceiver
触摸输入事件的回调函数,如果返回true,则触摸输入将被监听器消耗(系统执行关闭动作)。
触摸输入事件的回调函数。如果返回true,则触摸输入被监听器消耗,系统将执行关闭动作。
### (touchEvent: TouchEvent): Boolean
此接口为系统接口。
触摸输入事件的回调函数。函数名由使用者定义,这里是函数调用时必须符合的格式,传入参数必须为TouchEvent类型,返回值为Boolean类型。
**系统能力:**
SystemCapability.MultimodalInput.Input.InputMonitor
**系统能力:**
SystemCapability.MultimodalInput.Input.InputMonitor
...
@@ -132,15 +86,15 @@ inputMonitor.off("mouse");
...
@@ -132,15 +86,15 @@ inputMonitor.off("mouse");
| touchEvent |
[
TouchEvent
](
../arkui-js/js-components-common-events.md
)
| 是 | 触摸输入事件回调函数,返回true表示输触事件被监听器消费,false表示输触事件未被监听器消费。 |
| touchEvent |
[
TouchEvent
](
../arkui-js/js-components-common-events.md
)
| 是 | 触摸输入事件回调函数,返回true表示输触事件被监听器消费,false表示输触事件未被监听器消费。 |
**返回值:**
**返回值:**
| 类型
| 说明
|
| 类型
| 说明
|
| ------- | -------------------------------------- |
| ------- | -------------------------------------- |
| Boolean | 返回true表示
输触事件被监听器消费,false表示输触
事件未被监听器消费。 |
| Boolean | 返回true表示
触摸输入事件被监听器消费,false表示触摸输入
事件未被监听器消费。 |
**示例:**
**示例:**
```
js
```
js
inputMonitor
.
on
(
"
touch
"
,
(
event
)
=>
{
inputMonitor
.
on
(
"
touch
"
,
(
event
)
=>
{
// 消费触
屏
事件
// 消费触
摸输入
事件
return
false
;
return
false
;
});
});
inputMonitor
.
off
(
"
touch
"
);
inputMonitor
.
off
(
"
touch
"
);
...
...
zh-cn/application-dev/reference/apis/js-apis-keycode.md
浏览文件 @
ccd023ff
# 键值
# 键值
按键类设备
键值。
KeyCode模块提供了按键类设备的
键值。
>  **说明:**
>  **说明:**
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...
@@ -11,6 +11,8 @@
...
@@ -11,6 +11,8 @@
import
{
KeyCode
}
from
'
@ohos.multimodalInput.keyCode
'
import
{
KeyCode
}
from
'
@ohos.multimodalInput.keyCode
'
```
```
## KeyCode
**系统能力**
:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.Core
**系统能力**
:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.Core
| 名称 | 参数类型 | 可读 | 可写 | 描述 |
| 名称 | 参数类型 | 可读 | 可写 | 描述 |
...
...
zh-cn/application-dev/reference/apis/js-apis-keyevent.md
浏览文件 @
ccd023ff
# 按键输入事件
# 按键输入事件
设备
上报的按键事件。
KeyEvent模块提供了设备可以
上报的按键事件。
>  **说明:**
>  **说明:**
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录