Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
57c6321e
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看板
未验证
提交
57c6321e
编写于
6月 25, 2023
作者:
X
xixian
提交者:
Gitee
6月 25, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md.
Signed-off-by:
N
xixian
<
xixian@huawei.com
>
上级
e462fb47
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
54 addition
and
54 deletion
+54
-54
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md
+54
-54
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md
浏览文件 @
57c6321e
# @ohos.multimodalInput.inputMonitor (输入监听)
输入监听模块,提供了监听输入设备事件(当前支持触
摸屏和鼠标
)的能力。
输入监听模块,提供了监听输入设备事件(当前支持触
屏、鼠标和触控板手势
)的能力。
> **说明:**
>
...
...
@@ -17,11 +17,11 @@ import inputMonitor from '@ohos.multimodalInput.inputMonitor';
```
## inputMonitor.on
## inputMonitor.on
('touch')
on(type:
"touch"
, receiver: TouchEventReceiver): void
on(type:
'touch'
, receiver: TouchEventReceiver): void
开始
监听全局触屏事件。
监听全局触屏事件。
**需要权限:**
ohos.permission.INPUT_MONITORING
...
...
@@ -38,7 +38,7 @@ on(type: "touch", receiver: TouchEventReceiver): void
```
js
try
{
inputMonitor
.
on
(
"
touch
"
,
(
touchEvent
)
=>
{
inputMonitor
.
on
(
'
touch
'
,
(
touchEvent
)
=>
{
console
.
log
(
`Monitor on success
${
JSON
.
stringify
(
touchEvent
)}
`
);
return
false
;
});
...
...
@@ -47,11 +47,11 @@ try {
}
```
## inputMonitor.on<sup>9+</sup>
## inputMonitor.on
('mouse')
<sup>9+</sup>
on(type:
"mouse"
, receiver: Callback
<
MouseEvent
>
): void
on(type:
'mouse'
, receiver: Callback
<
MouseEvent
>
): void
开始
监听全局鼠标事件。
监听全局鼠标事件。
**需要权限:**
ohos.permission.INPUT_MONITORING
...
...
@@ -68,7 +68,7 @@ on(type: "mouse", receiver: Callback<MouseEvent>): void
```
js
try
{
inputMonitor
.
on
(
"
mouse
"
,
(
mouseEvent
)
=>
{
inputMonitor
.
on
(
'
mouse
'
,
(
mouseEvent
)
=>
{
console
.
log
(
`Monitor on success
${
JSON
.
stringify
(
mouseEvent
)}
`
);
return
false
;
});
...
...
@@ -79,11 +79,11 @@ try {
## inputMonitor.off
## inputMonitor.off
('touch')
off(type:
"touch"
, receiver?: TouchEventReceiver): void
off(type:
'touch'
, receiver?: TouchEventReceiver): void
停止
监听全局触屏事件。
取消
监听全局触屏事件。
**需要权限:**
ohos.permission.INPUT_MONITORING
...
...
@@ -105,8 +105,8 @@ function callback(touchEvent) {
return
false
;
};
try
{
inputMonitor
.
on
(
"
touch
"
,
callback
);
inputMonitor
.
off
(
"
touch
"
,
callback
);
inputMonitor
.
on
(
'
touch
'
,
callback
);
inputMonitor
.
off
(
'
touch
'
,
callback
);
console
.
log
(
`Monitor off success`
);
}
catch
(
error
)
{
console
.
log
(
`Monitor execute failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
...
...
@@ -120,19 +120,19 @@ function callback(touchEvent) {
return
false
;
};
try
{
inputMonitor
.
on
(
"
touch
"
,
callback
);
inputMonitor
.
off
(
"
touch
"
);
inputMonitor
.
on
(
'
touch
'
,
callback
);
inputMonitor
.
off
(
'
touch
'
);
console
.
log
(
`Monitor off success`
);
}
catch
(
error
)
{
console
.
log
(
`Monitor execute failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
}
```
## inputMonitor.off<sup>9+</sup>
## inputMonitor.off
('mouse')
<sup>9+</sup>
off(type:
"mouse"
, receiver?: Callback
<
MouseEvent
>
): void
off(type:
'mouse'
, receiver?: Callback
<
MouseEvent
>
): void
停止
监听全局鼠标事件。
取消
监听全局鼠标事件。
**需要权限:**
ohos.permission.INPUT_MONITORING
...
...
@@ -154,8 +154,8 @@ function callback(mouseEvent) {
return
false
;
};
try
{
inputMonitor
.
on
(
"
mouse
"
,
callback
);
inputMonitor
.
off
(
"
mouse
"
,
callback
);
inputMonitor
.
on
(
'
mouse
'
,
callback
);
inputMonitor
.
off
(
'
mouse
'
,
callback
);
console
.
log
(
`Monitor off success`
);
}
catch
(
error
)
{
console
.
log
(
`Monitor execute failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
...
...
@@ -169,8 +169,8 @@ function callback(mouseEvent) {
return
false
;
};
try
{
inputMonitor
.
on
(
"
mouse
"
,
callback
);
inputMonitor
.
off
(
"
mouse
"
);
inputMonitor
.
on
(
'
mouse
'
,
callback
);
inputMonitor
.
off
(
'
mouse
'
);
console
.
log
(
`Monitor off success`
);
}
catch
(
error
)
{
console
.
log
(
`Monitor execute failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
...
...
@@ -201,7 +201,7 @@ try {
```
js
try
{
inputMonitor
.
on
(
"
touch
"
,
touchEvent
=>
{
inputMonitor
.
on
(
'
touch
'
,
touchEvent
=>
{
if
(
touchEvent
.
touches
.
length
==
3
)
{
// 当前有三个手指按下
return
true
;
}
...
...
@@ -212,11 +212,11 @@ try {
}
```
## inputMonitor.on(
pinch
)<sup>10+</sup>
## inputMonitor.on(
'pinch'
)<sup>10+</sup>
on(type:
"pinch"
, receiver: Callback
<
[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)
>
): void
on(type:
'pinch'
, receiver: Callback
<
[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)
>
): void
开始监听全局
触控板捏合事件。
监听全局的
触控板捏合事件。
**需要权限:**
ohos.permission.INPUT_MONITORING
...
...
@@ -233,7 +233,7 @@ on(type: "pinch", receiver: Callback<[Pinch](js-apis-multimodalinput-gesturee
```
js
try
{
inputMonitor
.
on
(
"
pinch
"
,
(
pinchEvent
)
=>
{
inputMonitor
.
on
(
'
pinch
'
,
(
pinchEvent
)
=>
{
console
.
log
(
`Monitor on success
${
JSON
.
stringify
(
pinchEvent
)}
`
);
return
false
;
});
...
...
@@ -242,11 +242,11 @@ try {
}
```
## inputMonitor.off(
pinch
)<sup>10+</sup>
## inputMonitor.off(
'pinch'
)<sup>10+</sup>
off(type:
"pinch"
, receiver?: Callback
<
[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)
>
): void
off(type:
'pinch'
, receiver?: Callback
<
[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)
>
): void
停止监听全局
触控板捏合事件。
取消监听全局的
触控板捏合事件。
**需要权限:**
ohos.permission.INPUT_MONITORING
...
...
@@ -268,8 +268,8 @@ function callback(pinchEvent) {
return
false
;
};
try
{
inputMonitor
.
on
(
"
pinch
"
,
callback
);
inputMonitor
.
off
(
"
pinch
"
,
callback
);
inputMonitor
.
on
(
'
pinch
'
,
callback
);
inputMonitor
.
off
(
'
pinch
'
,
callback
);
console
.
log
(
`Monitor off success`
);
}
catch
(
error
)
{
console
.
log
(
`Monitor execute failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
...
...
@@ -283,19 +283,19 @@ function callback(pinchEvent) {
return
false
;
};
try
{
inputMonitor
.
on
(
"
pinch
"
,
callback
);
inputMonitor
.
off
(
"
pinch
"
);
inputMonitor
.
on
(
'
pinch
'
,
callback
);
inputMonitor
.
off
(
'
pinch
'
);
console
.
log
(
`Monitor off success`
);
}
catch
(
error
)
{
console
.
log
(
`Monitor execute failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
}
```
## inputMonitor.on(
threeFingersSwipe
)<sup>10+</sup>
## inputMonitor.on(
'threeFingersSwipe'
)<sup>10+</sup>
on(type:
"threeFingersSwipe"
, receiver: Callback
<
[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)
>
): void
on(type:
'threeFingersSwipe'
, receiver: Callback
<
[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)
>
): void
开始监听全局
触控板三指滑动事件。
监听全局的
触控板三指滑动事件。
**需要权限:**
ohos.permission.INPUT_MONITORING
...
...
@@ -312,7 +312,7 @@ on(type: "threeFingersSwipe", receiver: Callback<[ThreeFingersSwipe](js-apis-
```
js
try
{
inputMonitor
.
on
(
"
threeFingersSwipe
"
,
(
threeFingersSwipe
)
=>
{
inputMonitor
.
on
(
'
threeFingersSwipe
'
,
(
threeFingersSwipe
)
=>
{
console
.
log
(
`Monitor on success
${
JSON
.
stringify
(
threeFingersSwipe
)}
`
);
return
false
;
});
...
...
@@ -321,11 +321,11 @@ try {
}
```
## inputMonitor.off(
threeFingersSwipe
)<sup>10+</sup>
## inputMonitor.off(
'threeFingersSwipe'
)<sup>10+</sup>
off(type:
"threeFingersSwipe"
, receiver?: Callback
<
[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)
>
): void
off(type:
'threeFingersSwipe'
, receiver?: Callback
<
[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)
>
): void
停止监听全局
触控板三指滑动事件。
取消监听全局的
触控板三指滑动事件。
**需要权限:**
ohos.permission.INPUT_MONITORING
...
...
@@ -347,7 +347,7 @@ function callback(threeFingersSwipe) {
return
false
;
};
try
{
inputMonitor
.
on
(
"
threeFingersSwipe
"
,
callback
);
inputMonitor
.
on
(
'
threeFingersSwipe
'
,
callback
);
inputMonitor
.
off
(
"
threeFingersSwipe
"
,
callback
);
console
.
log
(
`Monitor off success`
);
}
catch
(
error
)
{
...
...
@@ -370,11 +370,11 @@ try {
}
```
## inputMonitor.on(
fourFingersSwipe
)<sup>10+</sup>
## inputMonitor.on(
'fourFingersSwipe'
)<sup>10+</sup>
on(type:
"fourFingersSwipe"
, receiver: Callback
<
[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)
>
): void
on(type:
'fourFingersSwipe'
, receiver: Callback
<
[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)
>
): void
开始监听全局
触控板四指滑动事件。
监听全局的
触控板四指滑动事件。
**需要权限:**
ohos.permission.INPUT_MONITORING
...
...
@@ -391,7 +391,7 @@ on(type: "fourFingersSwipe", receiver: Callback<[FourFingersSwipe](js-apis-mu
```
js
try
{
inputMonitor
.
on
(
"
fourFingersSwipe
"
,
(
fourFingersSwipe
)
=>
{
inputMonitor
.
on
(
'
fourFingersSwipe
'
,
(
fourFingersSwipe
)
=>
{
console
.
log
(
`Monitor on success
${
JSON
.
stringify
(
fourFingersSwipe
)}
`
);
return
false
;
});
...
...
@@ -400,11 +400,11 @@ try {
}
```
## inputMonitor.off(
fourFingersSwipe
)<sup>10+</sup>
## inputMonitor.off(
'fourFingersSwipe'
)<sup>10+</sup>
off(type:
"fourFingersSwipe"
, receiver?: Callback
<
[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)
>
): void
off(type:
'fourFingersSwipe'
, receiver?: Callback
<
[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)
>
): void
停止监听全局
触控板四指滑动事件。
取消监听全局的
触控板四指滑动事件。
**需要权限:**
ohos.permission.INPUT_MONITORING
...
...
@@ -426,8 +426,8 @@ function callback(fourFingersSwipe) {
return
false
;
};
try
{
inputMonitor
.
on
(
"
fourFingersSwipe
"
,
callback
);
inputMonitor
.
off
(
"
fourFingersSwipe
"
,
callback
);
inputMonitor
.
on
(
'
fourFingersSwipe
'
,
callback
);
inputMonitor
.
off
(
'
fourFingersSwipe
'
,
callback
);
console
.
log
(
`Monitor off success`
);
}
catch
(
error
)
{
console
.
log
(
`Monitor execute failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
...
...
@@ -441,8 +441,8 @@ function callback(fourFingersSwipe) {
return
false
;
};
try
{
inputMonitor
.
on
(
"
fourFingersSwipe
"
,
callback
);
inputMonitor
.
off
(
"
fourFingersSwipe
"
);
inputMonitor
.
on
(
'
fourFingersSwipe
'
,
callback
);
inputMonitor
.
off
(
'
fourFingersSwipe
'
);
console
.
log
(
`Monitor off success`
);
}
catch
(
error
)
{
console
.
log
(
`Monitor execute failed, error:
${
JSON
.
stringify
(
error
,
[
`code`
,
`message`
])}
`
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录