harmony 鸿蒙Shortcut Key Development
Shortcut Key Development
When to Use
You can set the delay for starting an ability using the shortcut key. An example is to take a screenshot 5 seconds after the shortcut key is pressed.
Modules to Import
import { shortKey } from '@kit.InputKit';
Available APIs
The following table lists the common APIs provided by the shortKey module. For details, see ohos.multimodalInput.shortKey.
API | Description |
---|---|
setKeyDownDuration(businessKey: string, delay: number, callback: AsyncCallback<void>): void | Sets the delay for starting an ability using the shortcut key. |
How to Develop
The following describes how to take a screenshot five seconds after the shortcut key is pressed.
import { shortKey } from '@kit.InputKit';
try {
shortKey.setKeyDownDuration("screenshot", 500, (error) => {// Set the delay to 5 seconds (500 ms)
if (error) {
console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Set key down duration success`);
});
} catch (error) {
console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
你可能感兴趣的鸿蒙文章
harmony 鸿蒙Input Kit (Multimodal Input)
harmony 鸿蒙Introduction to Input Kit
harmony 鸿蒙Combination Key Development
harmony 鸿蒙Input Device Development
harmony 鸿蒙Event Injection Development
harmony 鸿蒙Input Monitor Development
harmony 鸿蒙Event Interception Development (C/C++)
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦