1# @ohos.multimodalInput.shortKey (Shortcut Key) (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## Modules to Import 12 13```js 14import { shortKey } from '@kit.InputKit'; 15``` 16 17## shortKey.setKeyDownDuration 18 19setKeyDownDuration(businessKey: string, delay: number, callback: AsyncCallback<void>): void 20 21Sets the delay for starting an ability using shortcut keys. This API uses an asynchronous callback to return the result. 22 23**System capability**: SystemCapability.MultimodalInput.Input.ShortKey 24 25**Parameters** 26 27| Name | Type | Mandatory| Description | 28| ---------- | ------------------- | ---- | ------------------------------------------------------------ | 29| 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.| 30| delay | number | Yes | Delay for starting an ability using shortcut keys, in milliseconds. This field is invalid only when shortcut keys are used.| 31| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object. | 32 33**Error codes** 34 35For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 36 37| ID | Error Message | 38| ---- | --------------------- | 39| 202 | SystemAPI permission error. | 40| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | 41 42**Example** 43 44```js 45import { shortKey } from '@kit.InputKit'; 46try { 47 shortKey.setKeyDownDuration("businessId", 500, (error) => { 48 if (error) { 49 console.log(`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.log(`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 92import { shortKey } from '@kit.InputKit'; 93try { 94 shortKey.setKeyDownDuration("businessId", 500).then(() => { 95 console.log(`Set key down duration success`); 96 }); 97} catch (error) { 98 console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 99} 100``` 101 102## FingerprintAction<sup>12+</sup> 103 104Enumerates key event types. 105 106**System capability**: SystemCapability.MultimodalInput.Input.Core 107 108| Name | Value | Description | 109| ---------------------| ---------- | --------------------| 110| DOWN | 0x00000000 | Pressing down | 111| UP | 0x00000001 | Lifting up | 112| SLIDE | 0x00000002 | Sliding | 113| RETOUCH | 0x00000003 | Retouching | 114| CLICK | 0x00000004 | Clicking | 115 116 117## FingerprintEvent<sup>12+</sup> 118 119Defines the key event type and the offset position relative to the key. 120 121**System capability**: SystemCapability.MultimodalInput.Input.Core 122 123| Name | Type |Read Only | Optional |Description | 124| -------- | ------------------------ |-------|------ |-------- | 125| action | [FingerprintAction](#fingerprintaction12) | Yes | No |Key event type. | 126| 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.| 127| 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.| 128