1e41f4b71Sopenharmony_ci# @ohos.multimodalInput.shortKey (Shortcut Key) (System API) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **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. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> - 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. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> - The APIs provided by this module are system APIs. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## Modules to Import 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci```js 14e41f4b71Sopenharmony_ciimport { shortKey } from '@kit.InputKit'; 15e41f4b71Sopenharmony_ci``` 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci## shortKey.setKeyDownDuration 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_cisetKeyDownDuration(businessKey: string, delay: number, callback: AsyncCallback<void>): void 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ciSets the delay for starting an ability using shortcut keys. This API uses an asynchronous callback to return the result. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MultimodalInput.Input.ShortKey 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**Parameters** 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 28e41f4b71Sopenharmony_ci| ---------- | ------------------- | ---- | ------------------------------------------------------------ | 29e41f4b71Sopenharmony_ci| 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.| 30e41f4b71Sopenharmony_ci| delay | number | Yes | Delay for starting an ability using shortcut keys, in milliseconds. This field is invalid only when shortcut keys are used.| 31e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object. | 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci**Error codes** 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci| ID | Error Message | 38e41f4b71Sopenharmony_ci| ---- | --------------------- | 39e41f4b71Sopenharmony_ci| 202 | SystemAPI permission error. | 40e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci**Example** 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci```js 45e41f4b71Sopenharmony_ciimport { shortKey } from '@kit.InputKit'; 46e41f4b71Sopenharmony_citry { 47e41f4b71Sopenharmony_ci shortKey.setKeyDownDuration("businessId", 500, (error) => { 48e41f4b71Sopenharmony_ci if (error) { 49e41f4b71Sopenharmony_ci console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 50e41f4b71Sopenharmony_ci return; 51e41f4b71Sopenharmony_ci } 52e41f4b71Sopenharmony_ci console.log(`Set key down duration success`); 53e41f4b71Sopenharmony_ci }); 54e41f4b71Sopenharmony_ci} catch (error) { 55e41f4b71Sopenharmony_ci console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 56e41f4b71Sopenharmony_ci} 57e41f4b71Sopenharmony_ci``` 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci## shortKey.setKeyDownDuration 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_cisetKeyDownDuration(businessKey: string, delay: number): Promise<void> 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ciSets the delay for starting an ability using shortcut keys. This API uses a promise to return the result. 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MultimodalInput.Input.ShortKey 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci**Parameters** 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 70e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ------------------------------------------------------------ | 71e41f4b71Sopenharmony_ci| 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.| 72e41f4b71Sopenharmony_ci| delay | number | Yes | Delay for starting an ability using shortcut keys, in milliseconds. This field is invalid only when shortcut keys are used.| 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci**Return value** 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ci| Parameters | Description | 77e41f4b71Sopenharmony_ci| ------------- | ------------- | 78e41f4b71Sopenharmony_ci| Promise<void> | Promise that returns no value.| 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci**Error codes** 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci| ID | Error Message | 85e41f4b71Sopenharmony_ci| ---- | --------------------- | 86e41f4b71Sopenharmony_ci| 202 | SystemAPI permission error. | 87e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ci**Example** 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci```js 92e41f4b71Sopenharmony_ciimport { shortKey } from '@kit.InputKit'; 93e41f4b71Sopenharmony_citry { 94e41f4b71Sopenharmony_ci shortKey.setKeyDownDuration("businessId", 500).then(() => { 95e41f4b71Sopenharmony_ci console.log(`Set key down duration success`); 96e41f4b71Sopenharmony_ci }); 97e41f4b71Sopenharmony_ci} catch (error) { 98e41f4b71Sopenharmony_ci console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 99e41f4b71Sopenharmony_ci} 100e41f4b71Sopenharmony_ci``` 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ci## FingerprintAction<sup>12+</sup> 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ciEnumerates key event types. 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MultimodalInput.Input.Core 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci| Name | Value | Description | 109e41f4b71Sopenharmony_ci| ---------------------| ---------- | --------------------| 110e41f4b71Sopenharmony_ci| DOWN | 0x00000000 | Pressing down | 111e41f4b71Sopenharmony_ci| UP | 0x00000001 | Lifting up | 112e41f4b71Sopenharmony_ci| SLIDE | 0x00000002 | Sliding | 113e41f4b71Sopenharmony_ci| RETOUCH | 0x00000003 | Retouching | 114e41f4b71Sopenharmony_ci| CLICK | 0x00000004 | Clicking | 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ci## FingerprintEvent<sup>12+</sup> 118e41f4b71Sopenharmony_ci 119e41f4b71Sopenharmony_ciDefines the key event type and the offset position relative to the key. 120e41f4b71Sopenharmony_ci 121e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MultimodalInput.Input.Core 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ci| Name | Type |Read Only | Optional |Description | 124e41f4b71Sopenharmony_ci| -------- | ------------------------ |-------|------ |-------- | 125e41f4b71Sopenharmony_ci| action | [FingerprintAction](#fingerprintaction12) | Yes | No |Key event type. | 126e41f4b71Sopenharmony_ci| 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.| 127e41f4b71Sopenharmony_ci| 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