提交 cab04cb9 编写于 作者: Y Yuanxinying 提交者: PingPing2023

fixed 56b4f1c6 from https://gitee.com/pingping2023/docs/pulls/23965

update zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md.
UPDATE
Signed-off-by: NYuanxinying <yuanxinying@huawei.com>
上级 89efc799
......@@ -38,10 +38,17 @@ on(type: "key", keyOptions: KeyOptions, callback: Callback&lt;KeyOptions&gt;): v
```js
let leftAltKey = 2045;
let tabKey = 2049;
try {
inputConsumer.on("key", {preKeys: [leftAltKey], finalKey: tabKey, isFinalKeyDown: true, finalKeyDownDuration: 0}, keyOptions => {
let keyOptions: inputConsumer.KeyOptions = {
preKeys: [ leftAltKey ],
finalKey: tabKey,
isFinalKeyDown: true,
finalKeyDownDuration: 0
};
let callback = (keyOptions: inputConsumer.KeyOptions) => {
console.log(`keyOptions: ${JSON.stringify(keyOptions)}`);
});
}
try {
inputConsumer.on("key", keyOptions, callback);
} catch (error) {
console.log(`Subscribe failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
......@@ -70,10 +77,10 @@ off(type: "key", keyOptions: KeyOptions, callback?: Callback&lt;KeyOptions&gt;):
let leftAltKey = 2045;
let tabKey = 2049;
// 取消订阅单个回调函数
let callback = function (keyOptions) {
let callback = (keyOptions: inputConsumer.KeyOptions) => {
console.log(`keyOptions: ${JSON.stringify(keyOptions)}`);
}
let keyOption = {preKeys: [leftAltKey], finalKey: tabKey, isFinalKeyDown: true, finalKeyDownDuration: 0};
let keyOption: inputConsumer.KeyOptions = {preKeys: [leftAltKey], finalKey: tabKey, isFinalKeyDown: true, finalKeyDownDuration: 0};
try {
inputConsumer.on("key", keyOption, callback);
inputConsumer.off("key", keyOption, callback);
......@@ -86,10 +93,10 @@ try {
let leftAltKey = 2045;
let tabKey = 2049;
// 取消订阅所有回调函数
let callback = function (keyOptions) {
let callback = (keyOptions: inputConsumer.KeyOptions) => {
console.log(`keyOptions: ${JSON.stringify(keyOptions)}`);
}
let keyOption = {preKeys: [leftAltKey], finalKey: tabKey, isFinalKeyDown: true, finalKeyDownDuration: 0};
let keyOption: inputConsumer.KeyOptions = {preKeys: [leftAltKey], finalKey: tabKey, isFinalKeyDown: true, finalKeyDownDuration: 0};
try {
inputConsumer.on("key", keyOption, callback);
inputConsumer.off("key", keyOption);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册