1# @ohos.multimodalInput.shortKey (Preset Global Shortcut Keys) (System API) 2 3The **shortKey** module provides APIs to set the delay for starting an ability using a shortcut key. For example, you can set the delay to 3 seconds so that a screenshot is taken when you press and hold the shortcut key for 3 seconds. 4 5> **NOTE** 6> 7> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> 9> - The APIs provided by this module are system APIs. 10 11 12## Modules to Import 13 14```js 15import { shortKey } from '@kit.InputKit'; 16``` 17 18## shortKey.setKeyDownDuration 19 20setKeyDownDuration(businessKey: string, delay: number, callback: AsyncCallback<void>): void 21 22Sets the delay for starting an ability using shortcut keys. This API uses an asynchronous callback to return the result. 23 24**System capability**: SystemCapability.MultimodalInput.Input.ShortKey 25 26**Parameters** 27 28| Name | Type | Mandatory| Description | 29| ---------- | ------------------- | ---- | ------------------------------------------------------------ | 30| businessKey| string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file. You need to query this parameter on your own before calling the API.| 31| delay | number | Yes | Delay for starting an ability using shortcut keys, in milliseconds. This field is invalid only when shortcut keys are used.| 32| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.| 33 34**Error codes** 35 36For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 37 38| ID | Error Message | 39| ---- | --------------------- | 40| 202 | SystemAPI permission error. | 41| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | 42 43**Example** 44 45```js 46try { 47 shortKey.setKeyDownDuration("businessId", 500, (error) => { 48 if (error) { 49 console.error(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 50 return; 51 } 52 console.log(`Set key down duration success`); 53 }); 54} catch (error) { 55 console.error(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 56} 57``` 58 59## shortKey.setKeyDownDuration 60 61setKeyDownDuration(businessKey: string, delay: number): Promise<void> 62 63Sets the delay for starting an ability using shortcut keys. This API uses a promise to return the result. 64 65**System capability**: SystemCapability.MultimodalInput.Input.ShortKey 66 67**Parameters** 68 69| Name | Type | Mandatory| Description | 70| ---------- | ------ | ---- | ------------------------------------------------------------ | 71| businessKey| string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file. You need to query this parameter on your own before calling the API.| 72| delay | number | Yes | Delay for starting an ability using shortcut keys, in milliseconds. This field is invalid only when shortcut keys are used.| 73 74**Return value** 75 76| Parameters | Description | 77| ------------- | ------------- | 78| Promise<void> | Promise that returns no value.| 79 80**Error codes** 81 82For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 83 84| ID | Error Message | 85| ---- | --------------------- | 86| 202 | SystemAPI permission error. | 87| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | 88 89**Example** 90 91```js 92try { 93 shortKey.setKeyDownDuration("businessId", 500).then(() => { 94 console.log(`Set key down duration success`); 95 }); 96} catch (error) { 97 console.error(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 98} 99``` 100 101## FingerprintAction<sup>12+</sup> 102 103Enumerates key event types. 104 105**System capability**: SystemCapability.MultimodalInput.Input.Core 106 107| Name | Value | Description | 108| ---------------------| ---------- | --------------------| 109| DOWN | 0x00000000 | Pressing down | 110| UP | 0x00000001 | Lifting up | 111| SLIDE | 0x00000002 | Sliding | 112| RETOUCH | 0x00000003 | Retouching | 113| CLICK | 0x00000004 | Clicking | 114 115 116## FingerprintEvent<sup>12+</sup> 117 118Defines the key event type and the offset position relative to the key. 119 120**System capability**: SystemCapability.MultimodalInput.Input.Core 121 122| Name | Type |Read Only | Optional |Description | 123| -------- | ------------------------ |-------|------ |-------- | 124| action | [FingerprintAction](#fingerprintaction12) | Yes | No |Key event type. | 125| distanceX | number | Yes | No |Offset position on the X axis. A positive number indicates that the pointer moves rightward, and a negative number indicates that the cursor moves leftward.| 126| distanceY | number | Yes | No |Offset position on the Y axis. A positive number indicates that the pointer moves upward, and a negative number indicates that the cursor moves downward.| 127