# @ohos.multimodalInput.inputDevice (Input Device) (System API) The **inputDevice** module allows you to listen for hot swap events of input devices and query information about input devices. > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > > This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.multimodalInput.inputDevice (Input Device)](js-apis-inputdevice.md). ## Modules to Import ```js import { inputDevice } from '@kit.InputKit'; ``` ## inputDevice.setKeyboardRepeatDelay10+ setKeyboardRepeatDelay(delay: number, callback: AsyncCallback<void>): void Sets the keyboard repeat delay. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System API**: This is a system API. **Parameters** | Name | Type | Mandatory| Description | | -------- | ------ | ---- | ------------------------------------------------------------ | | delay | number | Yes | Keyboard repeat delay, in ms. The value range is [300, 1000] and the default value is **500**.| | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). | ID | Error Message | | ---- | --------------------- | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | **Example** ```js try { inputDevice.setKeyboardRepeatDelay(350, (error: Error) => { if (error) { console.log(`Set keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`); return; } console.log(`Set keyboard repeat delay success`); }); } catch (error) { console.log(`Set keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` ## inputDevice.setKeyboardRepeatDelay10+ setKeyboardRepeatDelay(delay: number): Promise<void> Sets the keyboard repeat delay. This API uses a promise to return the result. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ------ | ---- | ----------------------------------- | | delay | number | Yes | Keyboard repeat delay, in ms. The value range is [300, 1000] and the default value is **500**.| **Return value** | Parameters | Description | | ------------------- | ---------------- | | Promise<void> | Promise used to return the result.| **Error codes** For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). | ID | Error Message | | ---- | --------------------- | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | **Example** ```js try { inputDevice.setKeyboardRepeatDelay(350).then(() => { console.log(`Set keyboard repeat delay success`); }); } catch (error) { console.log(`Set keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` ## inputDevice.getKeyboardRepeatDelay10+ getKeyboardRepeatDelay(callback: AsyncCallback<number>): void Obtains the keyboard repeat delay. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System API**: This is a system API. **Parameters** | Name | Type | Mandatory| Description | | -------- | ------ | ---- | ------------------------------------------------------------ | | callback | AsyncCallback<number> | Yes | Callback used to return the result.| **Error codes** For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). | ID | Error Message | | ---- | --------------------- | | 202 | SystemAPI permission error | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | **Example** ```js try { inputDevice.getKeyboardRepeatDelay((error: Error, delay: Number) => { if (error) { console.log(`Get keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`); return; } console.log(`Get keyboard repeat delay success`); }); } catch (error) { console.log(`Get keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` ## inputDevice.getKeyboardRepeatDelay10+ getKeyboardRepeatDelay(): Promise<number> Obtains the keyboard repeat delay. This API uses a promise to return the result. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System API**: This is a system API. **Return value** | Parameters | Description | | --------------------- | ------------------- | | Promise<number> | Promise used to return the result.| **Error codes** For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). | ID | Error Message | | ---- | --------------------- | | 202 | SystemAPI permission error | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | **Example** ```js try { inputDevice.getKeyboardRepeatDelay().then((delay: Number) => { console.log(`Get keyboard repeat delay success`); }); } catch (error) { console.log(`Get keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` ## inputDevice.setKeyboardRepeatRate10+ setKeyboardRepeatRate(rate: number, callback: AsyncCallback<void>): void Sets the keyboard repeat rate. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System API**: This is a system API. **Parameters** | Name | Type | Mandatory| Description | | -------- | ------ | ---- | ------------------------------------------------------------ | | rate | number | Yes | Keyboard repeat rate, in ms/time. The value range is [36, 100] and the default value is 50.| | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). | ID | Error Message | | ---- | --------------------- | | 202 | SystemAPI permission error | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | **Example** ```js try { inputDevice.setKeyboardRepeatRate(60, (error: Error) => { if (error) { console.log(`Set keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); return; } console.log(`Set keyboard repeat rate success`); }); } catch (error) { console.log(`Set keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` ## inputDevice.setKeyboardRepeatRate10+ setKeyboardRepeatRate(rate: number): Promise<void> Sets the keyboard repeat rate. This API uses a promise to return the result. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | ----- | ------ | ---- | ----------------------------------- | | rate | number | Yes | Keyboard repeat rate, in ms/time. The value range is [36, 100] and the default value is 50.| **Return value** | Parameters | Description | | ------------------- | ---------------- | | Promise<void> | Promise used to return the result.| **Error codes** For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). | ID | Error Message | | ---- | --------------------- | | 202 | SystemAPI permission error | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | **Example** ```js try { inputDevice.setKeyboardRepeatRate(60).then(() => { console.log(`Set keyboard repeat rate success`); }); } catch (error) { console.log(`Set keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` ## inputDevice.getKeyboardRepeatRate10+ getKeyboardRepeatRate(callback: AsyncCallback<number>): void Obtains the keyboard repeat rate. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System API**: This is a system API. **Parameters** | Name | Type | Mandatory | Description | | -------- | --------------------------- | ---- | -------------- | | callback | AsyncCallback<number> | Yes | Callback used to return the result.| **Error codes** For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). | ID | Error Message | | ---- | --------------------- | | 202 | SystemAPI permission error | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | **Example** ```js try { inputDevice.getKeyboardRepeatRate((error: Error, rate: Number) => { if (error) { console.log(`Get keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); return; } console.log(`Get keyboard repeat rate success`); }); } catch (error) { console.log(`Get keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` ## inputDevice.getKeyboardRepeatRate10+ getKeyboardRepeatRate(): Promise<number> Obtains the keyboard repeat rate. This API uses a promise to return the result. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice **System API**: This is a system API. **Return value** | Parameters | Description | | --------------------- | ------------------- | | Promise<number> | Promise used to return the result.| **Error codes** For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). | ID | Error Message | | ---- | --------------------- | | 202 | SystemAPI permission error | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. | **Example** ```js try { inputDevice.getKeyboardRepeatRate().then((rate: Number) => { console.log(`Get keyboard repeat rate success`); }); } catch (error) { console.log(`Get keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ```