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

!24108 【轻量级 PR】:update en/application-dev/reference/apis/js-apis-inputconsumer.md.

Merge pull request !24108 from gaoshangqi/N/A
......@@ -36,10 +36,17 @@ Enables listening for combination key events. This API uses an asynchronous call
```js
let leftAltKey = 2045;
let tabKey = 2049;
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", {preKeys: [leftAltKey], finalKey: tabKey, isFinalKeyDown: true, finalKeyDownDuration: 0}, keyOptions => {
console.log(`keyOptions: ${JSON.stringify(keyOptions)}`);
});
inputConsumer.on("key", keyOptions, callback);
} catch (error) {
console.log(`Subscribe failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
......@@ -68,10 +75,10 @@ Disables listening for combination key events.
let leftAltKey = 2045;
let tabKey = 2049;
// Disable listening for a single callback function.
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);
......@@ -84,10 +91,10 @@ try {
let leftAltKey = 2045;
let tabKey = 2049;
// Disable listening for all callback functions.
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.
先完成此消息的编辑!
想要评论请 注册