1# @ohos.multimodalInput.inputDevice (Input Device) (System API)
2
3
4The **inputDevice** module allows you to listen for hot swap events of input devices and query information about input devices.
5
6
7> **NOTE**
8>
9> 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.
10>
11> 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).
12
13
14## Modules to Import
15
16```js
17import { inputDevice } from '@kit.InputKit';
18```
19
20## inputDevice.setKeyboardRepeatDelay<sup>10+</sup>
21
22setKeyboardRepeatDelay(delay: number, callback: AsyncCallback&lt;void&gt;): void
23
24Sets the keyboard repeat delay. This API uses an asynchronous callback to return the result.
25
26**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
27
28**System API**: This is a system API.
29
30**Parameters**
31
32| Name    | Type  | Mandatory| Description                                                        |
33| -------- | ------ | ---- | ------------------------------------------------------------ |
34| delay    | number                    | Yes   | Keyboard repeat delay, in ms. The value range is [300, 1000] and the default value is **500**.|
35| callback | AsyncCallback&lt;void&gt; | Yes   | Callback used to return the result.|
36
37**Error codes**
38
39For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
40
41| ID | Error Message            |
42| ---- | --------------------- |
43| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
44
45**Example**
46
47```js
48try {
49  inputDevice.setKeyboardRepeatDelay(350, (error: Error) => {
50    if (error) {
51      console.log(`Set keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
52      return;
53    }
54    console.log(`Set keyboard repeat delay success`);
55  });
56} catch (error) {
57  console.log(`Set keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
58}
59```
60
61## inputDevice.setKeyboardRepeatDelay<sup>10+</sup>
62
63setKeyboardRepeatDelay(delay: number): Promise&lt;void&gt;
64
65Sets the keyboard repeat delay. This API uses a promise to return the result.
66
67**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
68
69**System API**: This is a system API.
70
71**Parameters**
72
73| Name   | Type    | Mandatory  | Description                                 |
74| ----- | ------ | ---- | ----------------------------------- |
75| delay | number | Yes   | Keyboard repeat delay, in ms. The value range is [300, 1000] and the default value is **500**.|
76
77**Return value**
78
79| Parameters                 | Description              |
80| ------------------- | ---------------- |
81| Promise&lt;void&gt; | Promise used to return the result.|
82
83**Error codes**
84
85For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
86
87| ID | Error Message            |
88| ---- | --------------------- |
89| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
90
91**Example**
92
93```js
94try {
95  inputDevice.setKeyboardRepeatDelay(350).then(() => {
96    console.log(`Set keyboard repeat delay success`);
97  });
98} catch (error) {
99  console.log(`Set keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
100}
101```
102
103## inputDevice.getKeyboardRepeatDelay<sup>10+</sup>
104
105getKeyboardRepeatDelay(callback: AsyncCallback&lt;number&gt;): void
106
107Obtains the keyboard repeat delay. This API uses an asynchronous callback to return the result.
108
109**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
110
111**System API**: This is a system API.
112
113**Parameters**
114
115| Name    | Type  | Mandatory| Description                                                        |
116| -------- | ------ | ---- | ------------------------------------------------------------ |
117| callback   | AsyncCallback&lt;number&gt;                    | Yes   | Callback used to return the result.|
118
119**Error codes**
120
121For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
122
123| ID | Error Message            |
124| ---- | --------------------- |
125| 202  | SystemAPI permission error |
126| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
127
128**Example**
129
130```js
131try {
132  inputDevice.getKeyboardRepeatDelay((error: Error, delay: Number) => {
133    if (error) {
134      console.log(`Get keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
135      return;
136    }
137    console.log(`Get keyboard repeat delay success`);
138  });
139} catch (error) {
140  console.log(`Get keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
141}
142```
143
144## inputDevice.getKeyboardRepeatDelay<sup>10+</sup>
145
146getKeyboardRepeatDelay(): Promise&lt;number&gt;
147
148Obtains the keyboard repeat delay. This API uses a promise to return the result.
149
150**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
151
152**System API**: This is a system API.
153
154**Return value**
155
156| Parameters                   | Description                 |
157| --------------------- | ------------------- |
158| Promise&lt;number&gt; | Promise used to return the result.|
159
160**Error codes**
161
162For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
163
164| ID | Error Message            |
165| ---- | --------------------- |
166| 202  | SystemAPI permission error |
167| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
168
169**Example**
170
171```js
172try {
173  inputDevice.getKeyboardRepeatDelay().then((delay: Number) => {
174    console.log(`Get keyboard repeat delay success`);
175  });
176} catch (error) {
177  console.log(`Get keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
178}
179```
180
181## inputDevice.setKeyboardRepeatRate<sup>10+</sup>
182
183setKeyboardRepeatRate(rate: number, callback: AsyncCallback&lt;void&gt;): void
184
185Sets the keyboard repeat rate. This API uses an asynchronous callback to return the result.
186
187**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
188
189**System API**: This is a system API.
190
191**Parameters**
192
193| Name    | Type  | Mandatory| Description                                                        |
194| -------- | ------ | ---- | ------------------------------------------------------------ |
195| rate    | number                    | Yes   | Keyboard repeat rate, in ms/time. The value range is [36, 100] and the default value is 50.|
196| callback | AsyncCallback&lt;void&gt; | Yes   | Callback used to return the result.|
197
198**Error codes**
199
200For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
201
202| ID | Error Message            |
203| ---- | --------------------- |
204| 202  | SystemAPI permission error |
205| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
206
207**Example**
208
209```js
210try {
211  inputDevice.setKeyboardRepeatRate(60, (error: Error) => {
212    if (error) {
213      console.log(`Set keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
214      return;
215    }
216    console.log(`Set keyboard repeat rate success`);
217  });
218} catch (error) {
219  console.log(`Set keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
220}
221```
222
223## inputDevice.setKeyboardRepeatRate<sup>10+</sup>
224
225setKeyboardRepeatRate(rate: number): Promise&lt;void&gt;
226
227Sets the keyboard repeat rate. This API uses a promise to return the result.
228
229**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
230
231**System API**: This is a system API.
232
233**Parameters**
234
235| Name   | Type    | Mandatory  | Description                                 |
236| ----- | ------ | ---- | ----------------------------------- |
237| rate | number | Yes   | Keyboard repeat rate, in ms/time. The value range is [36, 100] and the default value is 50.|
238
239**Return value**
240
241| Parameters                 | Description              |
242| ------------------- | ---------------- |
243| Promise&lt;void&gt; | Promise used to return the result.|
244
245**Error codes**
246
247For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
248
249| ID | Error Message            |
250| ---- | --------------------- |
251| 202  | SystemAPI permission error |
252| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
253
254**Example**
255
256```js
257try {
258  inputDevice.setKeyboardRepeatRate(60).then(() => {
259    console.log(`Set keyboard repeat rate success`);
260  });
261} catch (error) {
262  console.log(`Set keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
263}
264```
265
266## inputDevice.getKeyboardRepeatRate<sup>10+</sup>
267
268getKeyboardRepeatRate(callback: AsyncCallback&lt;number&gt;): void
269
270Obtains the keyboard repeat rate. This API uses an asynchronous callback to return the result.
271
272**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
273
274**System API**: This is a system API.
275
276**Parameters**
277
278| Name      | Type                         | Mandatory  | Description            |
279| -------- | --------------------------- | ---- | -------------- |
280| callback | AsyncCallback&lt;number&gt; | Yes   | Callback used to return the result.|
281
282**Error codes**
283
284For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
285
286| ID | Error Message            |
287| ---- | --------------------- |
288| 202  | SystemAPI permission error |
289| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
290
291**Example**
292
293```js
294try {
295  inputDevice.getKeyboardRepeatRate((error: Error, rate: Number) => {
296    if (error) {
297      console.log(`Get keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
298      return;
299    }
300    console.log(`Get keyboard repeat rate success`);
301  });
302} catch (error) {
303  console.log(`Get keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
304}
305```
306
307## inputDevice.getKeyboardRepeatRate<sup>10+</sup>
308
309getKeyboardRepeatRate(): Promise&lt;number&gt;
310
311Obtains the keyboard repeat rate. This API uses a promise to return the result.
312
313**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
314
315**System API**: This is a system API.
316
317**Return value**
318
319| Parameters                   | Description                 |
320| --------------------- | ------------------- |
321| Promise&lt;number&gt; | Promise used to return the result.|
322
323**Error codes**
324
325For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
326
327| ID | Error Message            |
328| ---- | --------------------- |
329| 202  | SystemAPI permission error |
330| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;2. Incorrect parameter types; 3. Parameter verification failed. |
331
332**Example**
333
334```js
335try {
336  inputDevice.getKeyboardRepeatRate().then((rate: Number) => {
337    console.log(`Get keyboard repeat rate success`);
338  });
339} catch (error) {
340  console.log(`Get keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
341}
342```
343