1e41f4b71Sopenharmony_ci# @ohos.inputMethod (Input Method Framework)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **inputMethod** module is oriented to common foreground applications (third-party applications and system applications such as Notes, Messaging, and Settings). It provides input method control and management capabilities, including displaying or hiding the soft keyboard, switching between input methods, and obtaining the list of all input methods.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Modules to Import
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci```ts
13e41f4b71Sopenharmony_ciimport { inputMethod } from '@kit.IMEKit';
14e41f4b71Sopenharmony_ci```
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci## Constants<sup>8+</sup>
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ciProvides the constants.
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci| Name| Type| Value| Description|
23e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
24e41f4b71Sopenharmony_ci| MAX_TYPE_NUM | number | 128 | Maximum number of supported input methods.|
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci## InputMethodProperty<sup>8+</sup>
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ciDescribes the input method application attributes.
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci| Name| Type| Read-only| Optional| Description|
33e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
34e41f4b71Sopenharmony_ci| name<sup>9+</sup>  | string | Yes| No| Mandatory. Name of the input method package.|
35e41f4b71Sopenharmony_ci| id<sup>9+</sup>    | string | Yes| No| Mandatory. Unique ID of the input method.|
36e41f4b71Sopenharmony_ci| label<sup>9+</sup>    | string | Yes| No| Optional. External name of the input method.|
37e41f4b71Sopenharmony_ci| labelId<sup>10+</sup>    | number | Yes| No| Optional. External ID of the input method.|
38e41f4b71Sopenharmony_ci| icon<sup>9+</sup>    | string | Yes| No| Optional. Icon of the input method. It can be obtained by using **iconId**. This parameter is reserved.|
39e41f4b71Sopenharmony_ci| iconId<sup>9+</sup>    | number | Yes| No| Optional. Icon ID of the input method.|
40e41f4b71Sopenharmony_ci| extra<sup>9+</sup>    | object | Yes| Yes| Extra information about the input method. This parameter is reserved and currently has no specific meaning.<br>- API version 10 and later: optional<br>- API version 9: mandatory|
41e41f4b71Sopenharmony_ci| packageName<sup>(deprecated)</sup> | string | Yes| No| Name of the input method package. Mandatory.<br>**NOTE**<br>This API is supported since API version 8 and deprecated since API version 9. You are advised to use **name** instead.|
42e41f4b71Sopenharmony_ci| methodId<sup>(deprecated)</sup> | string | Yes| No| Unique ID of the input method. Mandatory.<br>**NOTE**<br>This API is supported since API version 8 and deprecated since API version 9. You are advised to use **id** instead.|
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci## inputMethod.getController<sup>9+</sup>
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_cigetController(): InputMethodController
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ciObtains an [InputMethodController](#inputmethodcontroller) instance.
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci**Return value**
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci| Type                                           | Description                  |
55e41f4b71Sopenharmony_ci| ----------------------------------------------- | ---------------------- |
56e41f4b71Sopenharmony_ci| [InputMethodController](#inputmethodcontroller) | **InputMethodController** instance.|
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci**Error codes**
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md).
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci| ID| Error Message                    |
63e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
64e41f4b71Sopenharmony_ci| 12800006 | input method controller error. |
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci**Example**
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci```ts
69e41f4b71Sopenharmony_cilet inputMethodController = inputMethod.getController();
70e41f4b71Sopenharmony_ci```
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci## inputMethod.getDefaultInputMethod<sup>11+</sup>
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_cigetDefaultInputMethod(): InputMethodProperty
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ciObtains the default input method.
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci**Return value**
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci| Type                                        | Description                    |
83e41f4b71Sopenharmony_ci| -------------------------------------------- | ------------------------ |
84e41f4b71Sopenharmony_ci| [InputMethodProperty](#inputmethodproperty8) | Default input method.|
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci**Error codes**
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md).
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci| ID| Error Message                            |
91e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
92e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci**Example**
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci```ts
97e41f4b71Sopenharmony_citry {
98e41f4b71Sopenharmony_ci  let defaultIme = inputMethod.getDefaultInputMethod();
99e41f4b71Sopenharmony_ci} catch(err) {
100e41f4b71Sopenharmony_ci  console.error(`Failed to getDefaultInputMethod: ${JSON.stringify(err)}`);
101e41f4b71Sopenharmony_ci}
102e41f4b71Sopenharmony_ci```
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci## inputMethod.getSystemInputMethodConfigAbility<sup>11+</sup>
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_cigetSystemInputMethodConfigAbility(): ElementName
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ciObtains the information about the input method configuration page ability.
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci**Return value**
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci| Type                                        | Description                    |
115e41f4b71Sopenharmony_ci| -------------------------------------------- | ------------------------ |
116e41f4b71Sopenharmony_ci| [ElementName](../apis-ability-kit/js-apis-bundleManager-elementName.md) | Element name of the input method configuration page ability.|
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci**Error codes**
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md).
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci| ID| Error Message                            |
123e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
124e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci**Example**
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci```ts
129e41f4b71Sopenharmony_citry {
130e41f4b71Sopenharmony_ci  let inputMethodConfig = inputMethod.getSystemInputMethodConfigAbility();
131e41f4b71Sopenharmony_ci} catch(err) {
132e41f4b71Sopenharmony_ci  console.error(`Failed to get getSystemInputMethodConfigAbility: ${JSON.stringify(err)}`);
133e41f4b71Sopenharmony_ci}
134e41f4b71Sopenharmony_ci```
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_ci## inputMethod.getSetting<sup>9+</sup>
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_cigetSetting(): InputMethodSetting
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ciObtains an [InputMethodSetting](#inputmethodsetting8) instance.
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ci**Return value**
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci| Type                                     | Description                      |
147e41f4b71Sopenharmony_ci| ----------------------------------------- | -------------------------- |
148e41f4b71Sopenharmony_ci| [InputMethodSetting](#inputmethodsetting8) | **InputMethodSetting** instance.|
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci**Error codes**
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md).
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci| ID| Error Message                            |
155e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
156e41f4b71Sopenharmony_ci| 12800007 |  settings extension error. |
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci**Example**
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci```ts
161e41f4b71Sopenharmony_cilet inputMethodSetting = inputMethod.getSetting();
162e41f4b71Sopenharmony_ci```
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci## inputMethod.switchInputMethod<sup>9+</sup>
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ciswitchInputMethod(target: InputMethodProperty, callback: AsyncCallback&lt;boolean&gt;): void
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ciSwitches to another input method. This API uses an asynchronous callback to return the result.
169e41f4b71Sopenharmony_ci> **NOTE**
170e41f4b71Sopenharmony_ci>
171e41f4b71Sopenharmony_ci>  - In API versions 9 and 10, this API can only be called by system applications granted the **ohos.permission.CONNECT_IME_ABILITY** permission.
172e41f4b71Sopenharmony_ci>  - Since API version 11, this API can only be called by the current input method application.
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci**Parameters**
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
179e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
180e41f4b71Sopenharmony_ci| target | [InputMethodProperty](#inputmethodproperty8) | Yes| Target input method.|
181e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci**Error codes**
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci| ID| Error Message                            |
188e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
189e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
190e41f4b71Sopenharmony_ci| 12800005 | configuration persisting error.        |
191e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci**Example**
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci```ts
196e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_cilet currentIme = inputMethod.getCurrentInputMethod();
199e41f4b71Sopenharmony_citry{
200e41f4b71Sopenharmony_ci  inputMethod.switchInputMethod(currentIme, (err: BusinessError, result: boolean) => {
201e41f4b71Sopenharmony_ci    if (err) {
202e41f4b71Sopenharmony_ci      console.error(`Failed to switchInputMethod: ${JSON.stringify(err)}`);
203e41f4b71Sopenharmony_ci      return;
204e41f4b71Sopenharmony_ci    }
205e41f4b71Sopenharmony_ci    if (result) {
206e41f4b71Sopenharmony_ci      console.log('Succeeded in switching inputmethod.');
207e41f4b71Sopenharmony_ci    } else {
208e41f4b71Sopenharmony_ci      console.error('Failed to switchInputMethod.');
209e41f4b71Sopenharmony_ci    }
210e41f4b71Sopenharmony_ci  });
211e41f4b71Sopenharmony_ci} catch(err) {
212e41f4b71Sopenharmony_ci  console.error(`Failed to switchInputMethod: ${JSON.stringify(err)}`);
213e41f4b71Sopenharmony_ci}
214e41f4b71Sopenharmony_ci```
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci> **NOTE**
217e41f4b71Sopenharmony_ci>
218e41f4b71Sopenharmony_ci> Since API version 11, the error code "201 permissions check fails" is removed.
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci## inputMethod.switchInputMethod<sup>9+</sup>
221e41f4b71Sopenharmony_ciswitchInputMethod(target: InputMethodProperty): Promise&lt;boolean&gt;
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ciSwitches to another input method. This API uses a promise to return the result.
224e41f4b71Sopenharmony_ci> **NOTE**
225e41f4b71Sopenharmony_ci>
226e41f4b71Sopenharmony_ci>  - In API versions 9 and 10, this API can only be called by system applications granted the **ohos.permission.CONNECT_IME_ABILITY** permission.
227e41f4b71Sopenharmony_ci>  - Since API version 11, this API can only be called by the current input method application.
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci**Parameters**
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
234e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
235e41f4b71Sopenharmony_ci  |target |  [InputMethodProperty](#inputmethodproperty8)| Yes| Target input method.|
236e41f4b71Sopenharmony_ci
237e41f4b71Sopenharmony_ci**Return value**
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci  | Type                                     | Description                        |
240e41f4b71Sopenharmony_ci  | ----------------------------------------- | ---------------------------- |
241e41f4b71Sopenharmony_ci  | Promise\<boolean> | Promise used to return the result. The value **true** means that the switching is successful, and **false** means the opposite.|
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci**Error codes**
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci| ID| Error Message                            |
248e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
249e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
250e41f4b71Sopenharmony_ci| 12800005 | configuration persisting error.        |
251e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_ci**Example**
254e41f4b71Sopenharmony_ci
255e41f4b71Sopenharmony_ci```ts
256e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_cilet currentIme = inputMethod.getCurrentInputMethod();
259e41f4b71Sopenharmony_citry {
260e41f4b71Sopenharmony_ci  inputMethod.switchInputMethod(currentIme).then((result: boolean) => {
261e41f4b71Sopenharmony_ci    if (result) {
262e41f4b71Sopenharmony_ci      console.log('Succeeded in switching inputmethod.');
263e41f4b71Sopenharmony_ci    } else {
264e41f4b71Sopenharmony_ci      console.error('Failed to switchInputMethod.');
265e41f4b71Sopenharmony_ci    }
266e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
267e41f4b71Sopenharmony_ci    console.error(`Failed to switchInputMethod: ${JSON.stringify(err)}`);
268e41f4b71Sopenharmony_ci  })
269e41f4b71Sopenharmony_ci} catch (err) {
270e41f4b71Sopenharmony_ci  console.error(`Failed to switchInputMethod: ${JSON.stringify(err)}`);
271e41f4b71Sopenharmony_ci}
272e41f4b71Sopenharmony_ci```
273e41f4b71Sopenharmony_ci
274e41f4b71Sopenharmony_ci> **NOTE**
275e41f4b71Sopenharmony_ci>
276e41f4b71Sopenharmony_ci> Since API version 11, the error code "201 permissions check fails" is removed.
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ci## inputMethod.getCurrentInputMethod<sup>9+</sup>
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_cigetCurrentInputMethod(): InputMethodProperty
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ciObtains the current input method. This API returns the result synchronously.
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ci**Return value**
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_ci| Type                                        | Description                    |
289e41f4b71Sopenharmony_ci| -------------------------------------------- | ------------------------ |
290e41f4b71Sopenharmony_ci| [InputMethodProperty](#inputmethodproperty8) | **InputmethodProperty** instance of the current input method.|
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci**Example**
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ci```ts
295e41f4b71Sopenharmony_cilet currentIme = inputMethod.getCurrentInputMethod();
296e41f4b71Sopenharmony_ci```
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_ci## inputMethod.switchCurrentInputMethodSubtype<sup>9+</sup>
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ciswitchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallback\<boolean>): void
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ciSwitches to another subtype of this input method. This API uses an asynchronous callback to return the result.
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci> **NOTE**
305e41f4b71Sopenharmony_ci>
306e41f4b71Sopenharmony_ci>  - In API version 9 , this API can only be called by system applications granted the **ohos.permission.CONNECT_IME_ABILITY** permission.
307e41f4b71Sopenharmony_ci>  - In API version 10, this API can only be called by system applications and the current input method application, and the **ohos.permission.CONNECT_IME_ABILITY** permission is required.
308e41f4b71Sopenharmony_ci>  - Since API version 11, this API can only be called by the current input method application.
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci**Parameters**
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
315e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
316e41f4b71Sopenharmony_ci| target |  [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)| Yes| Target input method subtype.|
317e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
318e41f4b71Sopenharmony_ci
319e41f4b71Sopenharmony_ci**Error codes**
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci| ID| Error Message                            |
324e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
325e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
326e41f4b71Sopenharmony_ci| 12800005 | configuration persisting error.        |
327e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_ci**Example**
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci```ts
332e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
333e41f4b71Sopenharmony_ci
334e41f4b71Sopenharmony_citry {
335e41f4b71Sopenharmony_ci  let extra: Record<string, string> = {}
336e41f4b71Sopenharmony_ci  inputMethod.switchCurrentInputMethodSubtype({
337e41f4b71Sopenharmony_ci    id: "ServiceExtAbility",
338e41f4b71Sopenharmony_ci    label: "",
339e41f4b71Sopenharmony_ci    name: "com.example.kikakeyboard",
340e41f4b71Sopenharmony_ci    mode: "upper",
341e41f4b71Sopenharmony_ci    locale: "",
342e41f4b71Sopenharmony_ci    language: "",
343e41f4b71Sopenharmony_ci    icon: "",
344e41f4b71Sopenharmony_ci    iconId: 0,
345e41f4b71Sopenharmony_ci    extra: extra
346e41f4b71Sopenharmony_ci  }, (err: BusinessError, result: boolean) => {
347e41f4b71Sopenharmony_ci    if (err) {
348e41f4b71Sopenharmony_ci      console.error(`Failed to switchCurrentInputMethodSubtype: ${JSON.stringify(err)}`);
349e41f4b71Sopenharmony_ci      return;
350e41f4b71Sopenharmony_ci    }
351e41f4b71Sopenharmony_ci    if (result) {
352e41f4b71Sopenharmony_ci      console.log('Succeeded in switching currentInputMethodSubtype.');
353e41f4b71Sopenharmony_ci    } else {
354e41f4b71Sopenharmony_ci      console.error('Failed to switchCurrentInputMethodSubtype');
355e41f4b71Sopenharmony_ci    }
356e41f4b71Sopenharmony_ci  });
357e41f4b71Sopenharmony_ci} catch(err) {
358e41f4b71Sopenharmony_ci  console.error(`Failed to switchCurrentInputMethodSubtype: ${JSON.stringify(err)}`);
359e41f4b71Sopenharmony_ci}
360e41f4b71Sopenharmony_ci```
361e41f4b71Sopenharmony_ci
362e41f4b71Sopenharmony_ci> **NOTE**
363e41f4b71Sopenharmony_ci>
364e41f4b71Sopenharmony_ci> Since API version 11, the error code "201 permissions check fails" is removed.
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci## inputMethod.switchCurrentInputMethodSubtype<sup>9+</sup>
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ciswitchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean&gt;
369e41f4b71Sopenharmony_ci
370e41f4b71Sopenharmony_ciSwitches to another subtype of this input method. This API uses a promise to return the result.
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_ci> **NOTE**
373e41f4b71Sopenharmony_ci>
374e41f4b71Sopenharmony_ci>  - In API version 9 , this API can only be called by system applications granted the **ohos.permission.CONNECT_IME_ABILITY** permission.
375e41f4b71Sopenharmony_ci>  - In API version 10, this API can only be called by system applications and the current input method application, and the **ohos.permission.CONNECT_IME_ABILITY** permission is required.
376e41f4b71Sopenharmony_ci>  - Since API version 11, this API can only be called by the current input method application.
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
379e41f4b71Sopenharmony_ci
380e41f4b71Sopenharmony_ci**Parameters**
381e41f4b71Sopenharmony_ci
382e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
383e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
384e41f4b71Sopenharmony_ci|target |  [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)| Yes| Target input method subtype.|
385e41f4b71Sopenharmony_ci
386e41f4b71Sopenharmony_ci**Return value**
387e41f4b71Sopenharmony_ci
388e41f4b71Sopenharmony_ci| Type                                     | Description                        |
389e41f4b71Sopenharmony_ci| ----------------------------------------- | ---------------------------- |
390e41f4b71Sopenharmony_ci| Promise\<boolean> | Promise used to return the result. The value **true** means that the switching is successful, and **false** means the opposite.|
391e41f4b71Sopenharmony_ci
392e41f4b71Sopenharmony_ci**Error codes**
393e41f4b71Sopenharmony_ci
394e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
395e41f4b71Sopenharmony_ci
396e41f4b71Sopenharmony_ci| ID| Error Message                            |
397e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
398e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
399e41f4b71Sopenharmony_ci| 12800005 | configuration persisting error.        |
400e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
401e41f4b71Sopenharmony_ci
402e41f4b71Sopenharmony_ci**Example**
403e41f4b71Sopenharmony_ci
404e41f4b71Sopenharmony_ci```ts
405e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
406e41f4b71Sopenharmony_ci
407e41f4b71Sopenharmony_citry {
408e41f4b71Sopenharmony_ci  let extra: Record<string, string> = {}
409e41f4b71Sopenharmony_ci  inputMethod.switchCurrentInputMethodSubtype({
410e41f4b71Sopenharmony_ci    id: "ServiceExtAbility",
411e41f4b71Sopenharmony_ci    label: "",
412e41f4b71Sopenharmony_ci    name: "com.example.kikakeyboard",
413e41f4b71Sopenharmony_ci    mode: "upper",
414e41f4b71Sopenharmony_ci    locale: "",
415e41f4b71Sopenharmony_ci    language: "",
416e41f4b71Sopenharmony_ci    icon: "",
417e41f4b71Sopenharmony_ci    iconId: 0,
418e41f4b71Sopenharmony_ci    extra: extra
419e41f4b71Sopenharmony_ci  }).then((result: boolean) => {
420e41f4b71Sopenharmony_ci    if (result) {
421e41f4b71Sopenharmony_ci      console.log('Succeeded in switching currentInputMethodSubtype.');
422e41f4b71Sopenharmony_ci    } else {
423e41f4b71Sopenharmony_ci      console.error('Failed to switchCurrentInputMethodSubtype.');
424e41f4b71Sopenharmony_ci    }
425e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
426e41f4b71Sopenharmony_ci    console.error(`Failed to switchCurrentInputMethodSubtype: ${JSON.stringify(err)}`);
427e41f4b71Sopenharmony_ci  })
428e41f4b71Sopenharmony_ci} catch(err) {
429e41f4b71Sopenharmony_ci  console.error(`Failed to switchCurrentInputMethodSubtype: ${JSON.stringify(err)}`);
430e41f4b71Sopenharmony_ci}
431e41f4b71Sopenharmony_ci```
432e41f4b71Sopenharmony_ci
433e41f4b71Sopenharmony_ci> **NOTE**
434e41f4b71Sopenharmony_ci>
435e41f4b71Sopenharmony_ci> Since API version 11, the error code "201 permissions check fails" is removed.
436e41f4b71Sopenharmony_ci
437e41f4b71Sopenharmony_ci## inputMethod.getCurrentInputMethodSubtype<sup>9+</sup>
438e41f4b71Sopenharmony_ci
439e41f4b71Sopenharmony_cigetCurrentInputMethodSubtype(): InputMethodSubtype
440e41f4b71Sopenharmony_ci
441e41f4b71Sopenharmony_ciObtains the current input method subtype.
442e41f4b71Sopenharmony_ci
443e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
444e41f4b71Sopenharmony_ci
445e41f4b71Sopenharmony_ci**Return value**
446e41f4b71Sopenharmony_ci
447e41f4b71Sopenharmony_ci| Type                                        | Description                    |
448e41f4b71Sopenharmony_ci| -------------------------------------------- | ------------------------ |
449e41f4b71Sopenharmony_ci| [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype) | Current input method subtype.|
450e41f4b71Sopenharmony_ci
451e41f4b71Sopenharmony_ci**Example**
452e41f4b71Sopenharmony_ci
453e41f4b71Sopenharmony_ci```ts
454e41f4b71Sopenharmony_cilet currentImeSubType = inputMethod.getCurrentInputMethodSubtype();
455e41f4b71Sopenharmony_ci```
456e41f4b71Sopenharmony_ci
457e41f4b71Sopenharmony_ci## inputMethod.switchCurrentInputMethodAndSubtype<sup>9+</sup>
458e41f4b71Sopenharmony_ci
459e41f4b71Sopenharmony_ciswitchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype, callback: AsyncCallback\<boolean>): void
460e41f4b71Sopenharmony_ci
461e41f4b71Sopenharmony_ciSwitches to a specified subtype of a specified input method. This API uses an asynchronous callback to return the result.
462e41f4b71Sopenharmony_ci
463e41f4b71Sopenharmony_ci> **NOTE**
464e41f4b71Sopenharmony_ci>
465e41f4b71Sopenharmony_ci>  - In API versions 9 and 10, this API can only be called by system applications granted the **ohos.permission.CONNECT_IME_ABILITY** permission.
466e41f4b71Sopenharmony_ci>  - Since API version 11, this API can only be called by the current input method application.
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
469e41f4b71Sopenharmony_ci
470e41f4b71Sopenharmony_ci**Parameters**
471e41f4b71Sopenharmony_ci
472e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
473e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
474e41f4b71Sopenharmony_ci|inputMethodProperty |  [InputMethodProperty](#inputmethodproperty8)| Yes| Target input method.|
475e41f4b71Sopenharmony_ci|inputMethodSubtype |  [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)| Yes| Target input method subtype.|
476e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
477e41f4b71Sopenharmony_ci
478e41f4b71Sopenharmony_ci**Error codes**
479e41f4b71Sopenharmony_ci
480e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ci| ID| Error Message                            |
483e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
484e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
485e41f4b71Sopenharmony_ci| 12800005 | configuration persisting error.        |
486e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
487e41f4b71Sopenharmony_ci
488e41f4b71Sopenharmony_ci**Example**
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_ci```ts
491e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
492e41f4b71Sopenharmony_ci
493e41f4b71Sopenharmony_cilet currentIme = inputMethod.getCurrentInputMethod();
494e41f4b71Sopenharmony_cilet imSubType = inputMethod.getCurrentInputMethodSubtype();
495e41f4b71Sopenharmony_citry {
496e41f4b71Sopenharmony_ci  inputMethod.switchCurrentInputMethodAndSubtype(currentIme, imSubType, (err: BusinessError, result: boolean) => {
497e41f4b71Sopenharmony_ci    if (err) {
498e41f4b71Sopenharmony_ci      console.error(`Failed to switchCurrentInputMethodAndSubtype: ${JSON.stringify(err)}`);
499e41f4b71Sopenharmony_ci      return;
500e41f4b71Sopenharmony_ci    }
501e41f4b71Sopenharmony_ci    if (result) {
502e41f4b71Sopenharmony_ci      console.log('Succeeded in switching currentInputMethodAndSubtype.');
503e41f4b71Sopenharmony_ci    } else {
504e41f4b71Sopenharmony_ci      console.error('Failed to switchCurrentInputMethodAndSubtype.');
505e41f4b71Sopenharmony_ci    }
506e41f4b71Sopenharmony_ci  });
507e41f4b71Sopenharmony_ci} catch (err) {
508e41f4b71Sopenharmony_ci  console.error(`Failed to switchCurrentInputMethodAndSubtype: ${JSON.stringify(err)}`);
509e41f4b71Sopenharmony_ci}
510e41f4b71Sopenharmony_ci```
511e41f4b71Sopenharmony_ci
512e41f4b71Sopenharmony_ci> **NOTE**
513e41f4b71Sopenharmony_ci>
514e41f4b71Sopenharmony_ci> Since API version 11, the error code "201 permissions check fails" is removed.
515e41f4b71Sopenharmony_ci
516e41f4b71Sopenharmony_ci## inputMethod.switchCurrentInputMethodAndSubtype<sup>9+</sup>
517e41f4b71Sopenharmony_ci
518e41f4b71Sopenharmony_ciswitchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype): Promise&lt;boolean&gt;
519e41f4b71Sopenharmony_ci
520e41f4b71Sopenharmony_ciSwitches to a specified subtype of a specified input method. This API uses a promise to return the result.
521e41f4b71Sopenharmony_ci
522e41f4b71Sopenharmony_ci> **NOTE**
523e41f4b71Sopenharmony_ci>
524e41f4b71Sopenharmony_ci>  - In API versions 9 and 10, this API can only be called by system applications granted the **ohos.permission.CONNECT_IME_ABILITY** permission.
525e41f4b71Sopenharmony_ci>  - Since API version 11, this API can only be called by the current input method application.
526e41f4b71Sopenharmony_ci
527e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
528e41f4b71Sopenharmony_ci
529e41f4b71Sopenharmony_ci**Parameters**
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
532e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
533e41f4b71Sopenharmony_ci|inputMethodProperty |  [InputMethodProperty](#inputmethodproperty8)| Yes| Target input method.|
534e41f4b71Sopenharmony_ci|inputMethodSubtype |  [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)| Yes| Target input method subtype.|
535e41f4b71Sopenharmony_ci
536e41f4b71Sopenharmony_ci**Return value**
537e41f4b71Sopenharmony_ci
538e41f4b71Sopenharmony_ci| Type                                     | Description                        |
539e41f4b71Sopenharmony_ci| ----------------------------------------- | ---------------------------- |
540e41f4b71Sopenharmony_ci| Promise\<boolean> | Promise used to return the result. The value **true** means that the switching is successful, and **false** means the opposite.|
541e41f4b71Sopenharmony_ci
542e41f4b71Sopenharmony_ci**Error codes**
543e41f4b71Sopenharmony_ci
544e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
545e41f4b71Sopenharmony_ci
546e41f4b71Sopenharmony_ci| ID| Error Message                            |
547e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
548e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
549e41f4b71Sopenharmony_ci| 12800005 | configuration persisting error.        |
550e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
551e41f4b71Sopenharmony_ci
552e41f4b71Sopenharmony_ci**Example**
553e41f4b71Sopenharmony_ci
554e41f4b71Sopenharmony_ci```ts
555e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
556e41f4b71Sopenharmony_ci
557e41f4b71Sopenharmony_cilet currentIme = inputMethod.getCurrentInputMethod();
558e41f4b71Sopenharmony_cilet imSubType = inputMethod.getCurrentInputMethodSubtype();
559e41f4b71Sopenharmony_citry {
560e41f4b71Sopenharmony_ci  inputMethod.switchCurrentInputMethodAndSubtype(currentIme, imSubType).then((result: boolean) => {
561e41f4b71Sopenharmony_ci    if (result) {
562e41f4b71Sopenharmony_ci      console.log('Succeeded in switching currentInputMethodAndSubtype.');
563e41f4b71Sopenharmony_ci    } else {
564e41f4b71Sopenharmony_ci      console.error('Failed to switchCurrentInputMethodAndSubtype.');
565e41f4b71Sopenharmony_ci    }
566e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
567e41f4b71Sopenharmony_ci    console.error(`Failed to switchCurrentInputMethodAndSubtype: ${JSON.stringify(err)}`);
568e41f4b71Sopenharmony_ci  })
569e41f4b71Sopenharmony_ci} catch(err) {
570e41f4b71Sopenharmony_ci  console.error(`Failed to switchCurrentInputMethodAndSubtype: ${JSON.stringify(err)}`);
571e41f4b71Sopenharmony_ci}
572e41f4b71Sopenharmony_ci```
573e41f4b71Sopenharmony_ci
574e41f4b71Sopenharmony_ci> **NOTE**
575e41f4b71Sopenharmony_ci>
576e41f4b71Sopenharmony_ci> Since API version 11, the error code "201 permissions check fails" is removed.
577e41f4b71Sopenharmony_ci
578e41f4b71Sopenharmony_ci## inputMethod.getInputMethodController<sup>(deprecated)</sup>
579e41f4b71Sopenharmony_ci
580e41f4b71Sopenharmony_cigetInputMethodController(): InputMethodController
581e41f4b71Sopenharmony_ci
582e41f4b71Sopenharmony_ciObtains an [InputMethodController](#inputmethodcontroller) instance.
583e41f4b71Sopenharmony_ci
584e41f4b71Sopenharmony_ci> **NOTE**
585e41f4b71Sopenharmony_ci>
586e41f4b71Sopenharmony_ci> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [getController()](#inputmethodgetcontroller9) instead.
587e41f4b71Sopenharmony_ci
588e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
589e41f4b71Sopenharmony_ci
590e41f4b71Sopenharmony_ci**Return value**
591e41f4b71Sopenharmony_ci
592e41f4b71Sopenharmony_ci| Type                                           | Description                    |
593e41f4b71Sopenharmony_ci| ----------------------------------------------- | ------------------------ |
594e41f4b71Sopenharmony_ci| [InputMethodController](#inputmethodcontroller) | Current **InputMethodController** instance.|
595e41f4b71Sopenharmony_ci
596e41f4b71Sopenharmony_ci**Example**
597e41f4b71Sopenharmony_ci
598e41f4b71Sopenharmony_ci```ts
599e41f4b71Sopenharmony_cilet inputMethodController = inputMethod.getInputMethodController();
600e41f4b71Sopenharmony_ci```
601e41f4b71Sopenharmony_ci
602e41f4b71Sopenharmony_ci## inputMethod.getInputMethodSetting<sup>(deprecated)</sup>
603e41f4b71Sopenharmony_ci
604e41f4b71Sopenharmony_cigetInputMethodSetting(): InputMethodSetting
605e41f4b71Sopenharmony_ci
606e41f4b71Sopenharmony_ciObtains an [InputMethodSetting](#inputmethodsetting8) instance.
607e41f4b71Sopenharmony_ci
608e41f4b71Sopenharmony_ci> **NOTE**
609e41f4b71Sopenharmony_ci>
610e41f4b71Sopenharmony_ci> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [getSetting()](#inputmethodgetsetting9) instead.
611e41f4b71Sopenharmony_ci
612e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
613e41f4b71Sopenharmony_ci
614e41f4b71Sopenharmony_ci**Return value**
615e41f4b71Sopenharmony_ci
616e41f4b71Sopenharmony_ci| Type                                     | Description                      |
617e41f4b71Sopenharmony_ci| ----------------------------------------- | -------------------------- |
618e41f4b71Sopenharmony_ci| [InputMethodSetting](#inputmethodsetting8) | **InputMethodSetting** instance.|
619e41f4b71Sopenharmony_ci
620e41f4b71Sopenharmony_ci**Example**
621e41f4b71Sopenharmony_ci
622e41f4b71Sopenharmony_ci```ts
623e41f4b71Sopenharmony_cilet inputMethodSetting = inputMethod.getInputMethodSetting();
624e41f4b71Sopenharmony_ci```
625e41f4b71Sopenharmony_ci
626e41f4b71Sopenharmony_ci## TextInputType<sup>10+</sup>
627e41f4b71Sopenharmony_ci
628e41f4b71Sopenharmony_ciEnumerates the text input types.
629e41f4b71Sopenharmony_ci
630e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
631e41f4b71Sopenharmony_ci
632e41f4b71Sopenharmony_ci| Name| Value|Description|
633e41f4b71Sopenharmony_ci| -------- | -------- |-------- |
634e41f4b71Sopenharmony_ci| NONE  | -1 |None.|
635e41f4b71Sopenharmony_ci| TEXT  | 0 |Text.|
636e41f4b71Sopenharmony_ci| MULTILINE  | 1 |Multi-line.|
637e41f4b71Sopenharmony_ci| NUMBER  | 2 |Number.|
638e41f4b71Sopenharmony_ci| PHONE  | 3 |Phone number.|
639e41f4b71Sopenharmony_ci| DATETIME  | 4 |Date.|
640e41f4b71Sopenharmony_ci| EMAIL_ADDRESS  | 5 |Email address.|
641e41f4b71Sopenharmony_ci| URL  | 6 |URL.|
642e41f4b71Sopenharmony_ci| VISIBLE_PASSWORD  | 7 |Password.|
643e41f4b71Sopenharmony_ci| NUMBER_PASSWORD<sup>11+</sup> | 8 |Numeric password.|
644e41f4b71Sopenharmony_ci
645e41f4b71Sopenharmony_ci## EnterKeyType<sup>10+</sup>
646e41f4b71Sopenharmony_ci
647e41f4b71Sopenharmony_ciEnumerates the function types represented by the Enter key of the input method.
648e41f4b71Sopenharmony_ci
649e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
650e41f4b71Sopenharmony_ci
651e41f4b71Sopenharmony_ci| Name| Value|Description|
652e41f4b71Sopenharmony_ci| -------- | -------- |-------- |
653e41f4b71Sopenharmony_ci| UNSPECIFIED  | 0 |Not specified.|
654e41f4b71Sopenharmony_ci| NONE  | 1 |None.|
655e41f4b71Sopenharmony_ci| GO  | 2 |Go.|
656e41f4b71Sopenharmony_ci| SEARCH  | 3 |Search.|
657e41f4b71Sopenharmony_ci| SEND  | 4 |Send.|
658e41f4b71Sopenharmony_ci| NEXT  | 5 |Next.|
659e41f4b71Sopenharmony_ci| DONE  | 6 |Done.|
660e41f4b71Sopenharmony_ci| PREVIOUS  | 7 |Previous.|
661e41f4b71Sopenharmony_ci| NEWLINE<sup>12+</sup>  | 8 | Line break.|
662e41f4b71Sopenharmony_ci
663e41f4b71Sopenharmony_ci## KeyboardStatus<sup>10+</sup>
664e41f4b71Sopenharmony_ci
665e41f4b71Sopenharmony_ciEnumerates the soft keyboard states of the input method.
666e41f4b71Sopenharmony_ci
667e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
668e41f4b71Sopenharmony_ci
669e41f4b71Sopenharmony_ci| Name| Value|Description|
670e41f4b71Sopenharmony_ci| -------- | -------- |-------- |
671e41f4b71Sopenharmony_ci| NONE  | 0 |None.|
672e41f4b71Sopenharmony_ci| HIDE  | 1 |Hidden.|
673e41f4b71Sopenharmony_ci| SHOW  | 2 |Shown.|
674e41f4b71Sopenharmony_ci
675e41f4b71Sopenharmony_ci## Direction<sup>10+</sup>
676e41f4b71Sopenharmony_ci
677e41f4b71Sopenharmony_ciEnumerates the directions of cursor movement of the input method.
678e41f4b71Sopenharmony_ci
679e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
680e41f4b71Sopenharmony_ci
681e41f4b71Sopenharmony_ci| Name| Value|Description|
682e41f4b71Sopenharmony_ci| -------- | -------- |-------- |
683e41f4b71Sopenharmony_ci| CURSOR_UP  | 1 |Upward.|
684e41f4b71Sopenharmony_ci| CURSOR_DOWN  | 2 |Downward.|
685e41f4b71Sopenharmony_ci| CURSOR_LEFT  | 3 |Leftward.|
686e41f4b71Sopenharmony_ci| CURSOR_RIGHT  | 4 |Rightward.|
687e41f4b71Sopenharmony_ci
688e41f4b71Sopenharmony_ci## ExtendAction<sup>10+</sup>
689e41f4b71Sopenharmony_ci
690e41f4b71Sopenharmony_ciDescribes the type of the extended edit action on the text box.
691e41f4b71Sopenharmony_ci
692e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
693e41f4b71Sopenharmony_ci
694e41f4b71Sopenharmony_ci| Name| Value|Description|
695e41f4b71Sopenharmony_ci| -------- | -------- |-------- |
696e41f4b71Sopenharmony_ci| SELECT_ALL  | 0 |Select all.|
697e41f4b71Sopenharmony_ci| CUT  | 3 |Cut.|
698e41f4b71Sopenharmony_ci| COPY  | 4 |Copy.|
699e41f4b71Sopenharmony_ci| PASTE  | 5 |Paste.|
700e41f4b71Sopenharmony_ci
701e41f4b71Sopenharmony_ci## FunctionKey<sup>10+</sup>
702e41f4b71Sopenharmony_ci
703e41f4b71Sopenharmony_ciDescribes the type of the input method function key.
704e41f4b71Sopenharmony_ci
705e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
706e41f4b71Sopenharmony_ci
707e41f4b71Sopenharmony_ci| Name| Type| Read-only| Optional| Description|
708e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
709e41f4b71Sopenharmony_ci| enterKeyType<sup>10+</sup>  | [EnterKeyType](#enterkeytype10) | Yes| Yes| Function type represented by the Enter key of the input method.|
710e41f4b71Sopenharmony_ci
711e41f4b71Sopenharmony_ci## InputAttribute<sup>10+</sup>
712e41f4b71Sopenharmony_ci
713e41f4b71Sopenharmony_ciDescribes the attributes of the edit box, including the text input type and Enter key function type.
714e41f4b71Sopenharmony_ci
715e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
716e41f4b71Sopenharmony_ci
717e41f4b71Sopenharmony_ci| Name| Type| Read-only| Optional| Description|
718e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
719e41f4b71Sopenharmony_ci| textInputType<sup>10+</sup>  | [TextInputType](#textinputtype10) | Yes| Yes| Enumerates the text input types.|
720e41f4b71Sopenharmony_ci| enterKeyType<sup>10+</sup>  | [EnterKeyType](#enterkeytype10) | Yes| Yes| Function type represented by the Enter key.|
721e41f4b71Sopenharmony_ci
722e41f4b71Sopenharmony_ci## TextConfig<sup>10+</sup>
723e41f4b71Sopenharmony_ci
724e41f4b71Sopenharmony_ciDescribes the configuration of the edit box.
725e41f4b71Sopenharmony_ci
726e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
727e41f4b71Sopenharmony_ci
728e41f4b71Sopenharmony_ci| Name| Type| Read-only| Optional| Description|
729e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
730e41f4b71Sopenharmony_ci| inputAttribute<sup>10+</sup>  | [InputAttribute](#inputattribute10) | No| Yes| Edit box attribute.|
731e41f4b71Sopenharmony_ci| cursorInfo<sup>10+</sup>  | [CursorInfo](#cursorinfo10) | No| No| Cursor information.|
732e41f4b71Sopenharmony_ci| selection<sup>10+</sup>  | [Range](#range10) | No| No| Text selection range.|
733e41f4b71Sopenharmony_ci| windowId<sup>10+</sup>  | number | No| No| ID of the window where the edit box is located.|
734e41f4b71Sopenharmony_ci
735e41f4b71Sopenharmony_ci## CursorInfo<sup>10+</sup>
736e41f4b71Sopenharmony_ci
737e41f4b71Sopenharmony_ciRepresents the cursor information.
738e41f4b71Sopenharmony_ci
739e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
740e41f4b71Sopenharmony_ci
741e41f4b71Sopenharmony_ci| Name| Type| Read-only| Optional| Description|
742e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
743e41f4b71Sopenharmony_ci| left  | number | Yes| Yes| Left coordinate of the cursor.|
744e41f4b71Sopenharmony_ci| top  | number | Yes| Yes| Top coordinate of the cursor.|
745e41f4b71Sopenharmony_ci| width  | number | Yes| Yes| Width of the cursor.|
746e41f4b71Sopenharmony_ci| height  | number | Yes| Yes| Height of the cursor.|
747e41f4b71Sopenharmony_ci
748e41f4b71Sopenharmony_ci## Range<sup>10+</sup>
749e41f4b71Sopenharmony_ci
750e41f4b71Sopenharmony_ciDescribes the range of the selected text.
751e41f4b71Sopenharmony_ci
752e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
753e41f4b71Sopenharmony_ci
754e41f4b71Sopenharmony_ci| Name| Type| Read-only| Optional| Description|
755e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
756e41f4b71Sopenharmony_ci| start  | number | Yes| Yes| Index of the first selected character in the text box.|
757e41f4b71Sopenharmony_ci| end  | number | Yes| Yes| Index of the last selected character in the text box.|
758e41f4b71Sopenharmony_ci
759e41f4b71Sopenharmony_ci## Movement<sup>10+</sup>
760e41f4b71Sopenharmony_ci
761e41f4b71Sopenharmony_ciDescribes the direction in which the cursor moves when the text is selected.
762e41f4b71Sopenharmony_ci
763e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
764e41f4b71Sopenharmony_ci
765e41f4b71Sopenharmony_ci| Name| Type| Read-only| Optional| Description|
766e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
767e41f4b71Sopenharmony_ci| direction  | [Direction](#direction10) | Yes| Yes| Direction in which the cursor moves when the text is selected.|
768e41f4b71Sopenharmony_ci
769e41f4b71Sopenharmony_ci## InputWindowInfo<sup>10+</sup>
770e41f4b71Sopenharmony_ci
771e41f4b71Sopenharmony_ciDescribes the window information of the input method keyboard.
772e41f4b71Sopenharmony_ci
773e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
774e41f4b71Sopenharmony_ci
775e41f4b71Sopenharmony_ci| Name| Type| Read-only| Optional| Description|
776e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
777e41f4b71Sopenharmony_ci| name  | string | Yes| Yes| Name of the input method keyboard window.|
778e41f4b71Sopenharmony_ci| left  | number | Yes| Yes| Horizontal coordinate of the upper left corner of the input method keyboard window, in px.|
779e41f4b71Sopenharmony_ci| top  | number | Yes| Yes| Vertical coordinate of the upper left corner of the input method keyboard window, in px.|
780e41f4b71Sopenharmony_ci| width  | number | Yes| Yes| Width of the input method keyboard window, in px.|
781e41f4b71Sopenharmony_ci| height  | number | Yes| Yes| Height of the input method keyboard window, in px.|
782e41f4b71Sopenharmony_ci
783e41f4b71Sopenharmony_ci## InputMethodController
784e41f4b71Sopenharmony_ci
785e41f4b71Sopenharmony_ciIn the following API examples, you must first use [getController](#inputmethodgetcontroller9) to obtain an **InputMethodController** instance, and then call the APIs using the obtained instance.
786e41f4b71Sopenharmony_ci
787e41f4b71Sopenharmony_ci### attach<sup>10+</sup>
788e41f4b71Sopenharmony_ci
789e41f4b71Sopenharmony_ciattach(showKeyboard: boolean, textConfig: TextConfig, callback: AsyncCallback&lt;void&gt;): void
790e41f4b71Sopenharmony_ci
791e41f4b71Sopenharmony_ciAttaches a self-drawing component to the input method. This API uses an asynchronous callback to return the result.
792e41f4b71Sopenharmony_ci
793e41f4b71Sopenharmony_ci> **NOTE**
794e41f4b71Sopenharmony_ci>
795e41f4b71Sopenharmony_ci> An input method can use the following features only when it has a self-drawing component attached to it: showing or hiding the keyboard, updating the cursor information, changing the selection range of the edit box, saving the configuration information, and listening for and processing the information or commands sent by the input method.
796e41f4b71Sopenharmony_ci
797e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
798e41f4b71Sopenharmony_ci
799e41f4b71Sopenharmony_ci**Parameters**
800e41f4b71Sopenharmony_ci
801e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
802e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
803e41f4b71Sopenharmony_ci| showKeyboard | boolean | Yes| Whether to start the input method keyboard after the self-drawing component is attached to the input method.<br>- The value **true** means to start the input method keyboard, and **false** means the opposite.|
804e41f4b71Sopenharmony_ci| textConfig | [TextConfig](#textconfig10) | Yes| Configuration of the edit box.|
805e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
806e41f4b71Sopenharmony_ci
807e41f4b71Sopenharmony_ci**Error codes**
808e41f4b71Sopenharmony_ci
809e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
810e41f4b71Sopenharmony_ci
811e41f4b71Sopenharmony_ci| ID| Error Message                            |
812e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
813e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
814e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
815e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
816e41f4b71Sopenharmony_ci
817e41f4b71Sopenharmony_ci**Example**
818e41f4b71Sopenharmony_ci
819e41f4b71Sopenharmony_ci```ts
820e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
821e41f4b71Sopenharmony_ci
822e41f4b71Sopenharmony_citry {
823e41f4b71Sopenharmony_ci  let textConfig: inputMethod.TextConfig = {
824e41f4b71Sopenharmony_ci    inputAttribute: {
825e41f4b71Sopenharmony_ci      textInputType: 0,
826e41f4b71Sopenharmony_ci      enterKeyType: 1
827e41f4b71Sopenharmony_ci    }
828e41f4b71Sopenharmony_ci  };
829e41f4b71Sopenharmony_ci  inputMethodController.attach(true, textConfig, (err: BusinessError) => {
830e41f4b71Sopenharmony_ci    if (err) {
831e41f4b71Sopenharmony_ci      console.error(`Failed to attach: ${JSON.stringify(err)}`);
832e41f4b71Sopenharmony_ci      return;
833e41f4b71Sopenharmony_ci    }
834e41f4b71Sopenharmony_ci    console.log('Succeeded in attaching the inputMethod.');
835e41f4b71Sopenharmony_ci  });
836e41f4b71Sopenharmony_ci} catch(err) {
837e41f4b71Sopenharmony_ci  console.error(`Failed to attach: ${JSON.stringify(err)}`);
838e41f4b71Sopenharmony_ci}
839e41f4b71Sopenharmony_ci```
840e41f4b71Sopenharmony_ci
841e41f4b71Sopenharmony_ci### attach<sup>10+</sup>
842e41f4b71Sopenharmony_ci
843e41f4b71Sopenharmony_ciattach(showKeyboard: boolean, textConfig: TextConfig): Promise&lt;void&gt;
844e41f4b71Sopenharmony_ci
845e41f4b71Sopenharmony_ciAttaches a self-drawing component to the input method. This API uses a promise to return the result.
846e41f4b71Sopenharmony_ci
847e41f4b71Sopenharmony_ci> **NOTE**
848e41f4b71Sopenharmony_ci>
849e41f4b71Sopenharmony_ci> An input method can use the following features only when it has a self-drawing component attached to it: showing or hiding the keyboard, updating the cursor information, changing the selection range of the edit box, saving the configuration information, and listening for and processing the information or commands sent by the input method.
850e41f4b71Sopenharmony_ci
851e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
852e41f4b71Sopenharmony_ci
853e41f4b71Sopenharmony_ci**Parameters**
854e41f4b71Sopenharmony_ci
855e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
856e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
857e41f4b71Sopenharmony_ci| showKeyboard | boolean | Yes| Whether to start the input method keyboard after the self-drawing component is attached to the input method.<br>- The value **true** means to start the input method keyboard, and **false** means the opposite.|
858e41f4b71Sopenharmony_ci| textConfig | [TextConfig](#textconfig10) | Yes| Configuration of the edit box.|
859e41f4b71Sopenharmony_ci
860e41f4b71Sopenharmony_ci**Return value**
861e41f4b71Sopenharmony_ci
862e41f4b71Sopenharmony_ci| Type| Description|
863e41f4b71Sopenharmony_ci| -------- | -------- |
864e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
865e41f4b71Sopenharmony_ci
866e41f4b71Sopenharmony_ci**Error codes**
867e41f4b71Sopenharmony_ci
868e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
869e41f4b71Sopenharmony_ci
870e41f4b71Sopenharmony_ci| ID| Error Message                            |
871e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
872e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
873e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
874e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
875e41f4b71Sopenharmony_ci
876e41f4b71Sopenharmony_ci**Example**
877e41f4b71Sopenharmony_ci
878e41f4b71Sopenharmony_ci```ts
879e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
880e41f4b71Sopenharmony_ci
881e41f4b71Sopenharmony_citry {
882e41f4b71Sopenharmony_ci  let textConfig: inputMethod.TextConfig = {
883e41f4b71Sopenharmony_ci    inputAttribute: {
884e41f4b71Sopenharmony_ci      textInputType: 0,
885e41f4b71Sopenharmony_ci      enterKeyType: 1
886e41f4b71Sopenharmony_ci    }
887e41f4b71Sopenharmony_ci  };
888e41f4b71Sopenharmony_ci  inputMethodController.attach(true, textConfig).then(() => {
889e41f4b71Sopenharmony_ci    console.log('Succeeded in attaching inputMethod.');
890e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
891e41f4b71Sopenharmony_ci    console.error(`Failed to attach: ${JSON.stringify(err)}`);
892e41f4b71Sopenharmony_ci  })
893e41f4b71Sopenharmony_ci} catch(err) {
894e41f4b71Sopenharmony_ci  console.error(`Failed to attach: ${JSON.stringify(err)}`);
895e41f4b71Sopenharmony_ci}
896e41f4b71Sopenharmony_ci```
897e41f4b71Sopenharmony_ci
898e41f4b71Sopenharmony_ci### showTextInput<sup>10+</sup>
899e41f4b71Sopenharmony_ci
900e41f4b71Sopenharmony_cishowTextInput(callback: AsyncCallback&lt;void&gt;): void
901e41f4b71Sopenharmony_ci
902e41f4b71Sopenharmony_ciEnters the text editing mode. This API uses an asynchronous callback to return the result.
903e41f4b71Sopenharmony_ci
904e41f4b71Sopenharmony_ci> **NOTE**
905e41f4b71Sopenharmony_ci>
906e41f4b71Sopenharmony_ci> After the edit box is attached to an input method, this API can be called to start the soft keyboard and enter the text editing state.
907e41f4b71Sopenharmony_ci
908e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
909e41f4b71Sopenharmony_ci
910e41f4b71Sopenharmony_ci**Parameters**
911e41f4b71Sopenharmony_ci
912e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
913e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
914e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
915e41f4b71Sopenharmony_ci
916e41f4b71Sopenharmony_ci**Error codes**
917e41f4b71Sopenharmony_ci
918e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md).
919e41f4b71Sopenharmony_ci
920e41f4b71Sopenharmony_ci| ID| Error Message                            |
921e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
922e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
923e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
924e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
925e41f4b71Sopenharmony_ci
926e41f4b71Sopenharmony_ci**Example**
927e41f4b71Sopenharmony_ci
928e41f4b71Sopenharmony_ci```ts
929e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
930e41f4b71Sopenharmony_ci
931e41f4b71Sopenharmony_ciinputMethodController.showTextInput((err: BusinessError) => {
932e41f4b71Sopenharmony_ci  if (err) {
933e41f4b71Sopenharmony_ci    console.error(`Failed to showTextInput: ${JSON.stringify(err)}`);
934e41f4b71Sopenharmony_ci    return;
935e41f4b71Sopenharmony_ci  }
936e41f4b71Sopenharmony_ci  console.log('Succeeded in showing the inputMethod.');
937e41f4b71Sopenharmony_ci});
938e41f4b71Sopenharmony_ci```
939e41f4b71Sopenharmony_ci
940e41f4b71Sopenharmony_ci### showTextInput<sup>10+</sup>
941e41f4b71Sopenharmony_ci
942e41f4b71Sopenharmony_cishowTextInput(): Promise&lt;void&gt;
943e41f4b71Sopenharmony_ci
944e41f4b71Sopenharmony_ciEnters the text editing mode. This API uses a promise to return the result.
945e41f4b71Sopenharmony_ci
946e41f4b71Sopenharmony_ci> **NOTE**
947e41f4b71Sopenharmony_ci>
948e41f4b71Sopenharmony_ci> After the edit box is attached to an input method, this API can be called to start the soft keyboard and enter the text editing state.
949e41f4b71Sopenharmony_ci
950e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
951e41f4b71Sopenharmony_ci
952e41f4b71Sopenharmony_ci**Return value**
953e41f4b71Sopenharmony_ci
954e41f4b71Sopenharmony_ci| Type| Description|
955e41f4b71Sopenharmony_ci| -------- | -------- |
956e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
957e41f4b71Sopenharmony_ci
958e41f4b71Sopenharmony_ci**Error codes**
959e41f4b71Sopenharmony_ci
960e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md).
961e41f4b71Sopenharmony_ci
962e41f4b71Sopenharmony_ci| ID| Error Message                            |
963e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
964e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
965e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
966e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
967e41f4b71Sopenharmony_ci
968e41f4b71Sopenharmony_ci**Example**
969e41f4b71Sopenharmony_ci
970e41f4b71Sopenharmony_ci```ts
971e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
972e41f4b71Sopenharmony_ci
973e41f4b71Sopenharmony_ciinputMethodController.showTextInput().then(() => {
974e41f4b71Sopenharmony_ci  console.log('Succeeded in showing text input.');
975e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
976e41f4b71Sopenharmony_ci  console.error(`Failed to showTextInput: ${JSON.stringify(err)}`);
977e41f4b71Sopenharmony_ci});
978e41f4b71Sopenharmony_ci```
979e41f4b71Sopenharmony_ci
980e41f4b71Sopenharmony_ci### hideTextInput<sup>10+</sup>
981e41f4b71Sopenharmony_ci
982e41f4b71Sopenharmony_cihideTextInput(callback: AsyncCallback&lt;void&gt;): void
983e41f4b71Sopenharmony_ci
984e41f4b71Sopenharmony_ciExits the text editing mode. This API uses an asynchronous callback to return the result.
985e41f4b71Sopenharmony_ci
986e41f4b71Sopenharmony_ci> **NOTE**
987e41f4b71Sopenharmony_ci>
988e41f4b71Sopenharmony_ci> If the soft keyboard is displayed when this API is called, it will be hidden.
989e41f4b71Sopenharmony_ci>
990e41f4b71Sopenharmony_ci> Calling this API does not detach the edit box from the input method. The edit box can call [showTextInput](#showtextinput10) again to reenter the text editing mode.
991e41f4b71Sopenharmony_ci
992e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
993e41f4b71Sopenharmony_ci
994e41f4b71Sopenharmony_ci**Parameters**
995e41f4b71Sopenharmony_ci
996e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
997e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
998e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
999e41f4b71Sopenharmony_ci
1000e41f4b71Sopenharmony_ci**Error codes**
1001e41f4b71Sopenharmony_ci
1002e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md).
1003e41f4b71Sopenharmony_ci
1004e41f4b71Sopenharmony_ci| ID| Error Message                            |
1005e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1006e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1007e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1008e41f4b71Sopenharmony_ci| 12800009 | input method client is detached.             |
1009e41f4b71Sopenharmony_ci
1010e41f4b71Sopenharmony_ci**Example**
1011e41f4b71Sopenharmony_ci
1012e41f4b71Sopenharmony_ci```ts
1013e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1014e41f4b71Sopenharmony_ci
1015e41f4b71Sopenharmony_ciinputMethodController.hideTextInput((err: BusinessError) => {
1016e41f4b71Sopenharmony_ci  if (err) {
1017e41f4b71Sopenharmony_ci    console.error(`Failed to hideTextInput: ${JSON.stringify(err)}`);
1018e41f4b71Sopenharmony_ci    return;
1019e41f4b71Sopenharmony_ci  }
1020e41f4b71Sopenharmony_ci  console.log('Succeeded in hiding text input.');
1021e41f4b71Sopenharmony_ci});
1022e41f4b71Sopenharmony_ci```
1023e41f4b71Sopenharmony_ci
1024e41f4b71Sopenharmony_ci### hideTextInput<sup>10+</sup>
1025e41f4b71Sopenharmony_ci
1026e41f4b71Sopenharmony_cihideTextInput(): Promise&lt;void&gt;
1027e41f4b71Sopenharmony_ci
1028e41f4b71Sopenharmony_ciExits the text editing mode. This API uses a promise to return the result.
1029e41f4b71Sopenharmony_ci
1030e41f4b71Sopenharmony_ci> **NOTE**
1031e41f4b71Sopenharmony_ci>
1032e41f4b71Sopenharmony_ci> If the soft keyboard is displayed when this API is called, it will be hidden.
1033e41f4b71Sopenharmony_ci>
1034e41f4b71Sopenharmony_ci> Calling this API does not detach the edit box from the input method. The edit box can call [showTextInput](#showtextinput10) again to reenter the text editing mode.
1035e41f4b71Sopenharmony_ci
1036e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1037e41f4b71Sopenharmony_ci
1038e41f4b71Sopenharmony_ci**Return value**
1039e41f4b71Sopenharmony_ci
1040e41f4b71Sopenharmony_ci| Type| Description|
1041e41f4b71Sopenharmony_ci| -------- | -------- |
1042e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
1043e41f4b71Sopenharmony_ci
1044e41f4b71Sopenharmony_ci**Error codes**
1045e41f4b71Sopenharmony_ci
1046e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md).
1047e41f4b71Sopenharmony_ci
1048e41f4b71Sopenharmony_ci| ID| Error Message                            |
1049e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1050e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1051e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1052e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
1053e41f4b71Sopenharmony_ci
1054e41f4b71Sopenharmony_ci**Example**
1055e41f4b71Sopenharmony_ci
1056e41f4b71Sopenharmony_ci```ts
1057e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1058e41f4b71Sopenharmony_ci
1059e41f4b71Sopenharmony_ciinputMethodController.hideTextInput().then(() => {
1060e41f4b71Sopenharmony_ci  console.log('Succeeded in hiding inputMethod.');
1061e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1062e41f4b71Sopenharmony_ci  console.error(`Failed to hideTextInput: ${JSON.stringify(err)}`);
1063e41f4b71Sopenharmony_ci})
1064e41f4b71Sopenharmony_ci```
1065e41f4b71Sopenharmony_ci
1066e41f4b71Sopenharmony_ci### detach<sup>10+</sup>
1067e41f4b71Sopenharmony_ci
1068e41f4b71Sopenharmony_cidetach(callback: AsyncCallback&lt;void&gt;): void
1069e41f4b71Sopenharmony_ci
1070e41f4b71Sopenharmony_ciDetaches the self-drawing component from the input method. This API uses an asynchronous callback to return the result.
1071e41f4b71Sopenharmony_ci
1072e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1073e41f4b71Sopenharmony_ci
1074e41f4b71Sopenharmony_ci**Parameters**
1075e41f4b71Sopenharmony_ci
1076e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
1077e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1078e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
1079e41f4b71Sopenharmony_ci
1080e41f4b71Sopenharmony_ci**Error codes**
1081e41f4b71Sopenharmony_ci
1082e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md).
1083e41f4b71Sopenharmony_ci
1084e41f4b71Sopenharmony_ci| ID| Error Message                            |
1085e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1086e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1087e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1088e41f4b71Sopenharmony_ci
1089e41f4b71Sopenharmony_ci**Example**
1090e41f4b71Sopenharmony_ci
1091e41f4b71Sopenharmony_ci```ts
1092e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1093e41f4b71Sopenharmony_ci
1094e41f4b71Sopenharmony_ciinputMethodController.detach((err: BusinessError) => {
1095e41f4b71Sopenharmony_ci  if (err) {
1096e41f4b71Sopenharmony_ci    console.error(`Failed to detach: ${JSON.stringify(err)}`);
1097e41f4b71Sopenharmony_ci    return;
1098e41f4b71Sopenharmony_ci  }
1099e41f4b71Sopenharmony_ci  console.log('Succeeded in detaching inputMethod.');
1100e41f4b71Sopenharmony_ci});
1101e41f4b71Sopenharmony_ci```
1102e41f4b71Sopenharmony_ci
1103e41f4b71Sopenharmony_ci### detach<sup>10+</sup>
1104e41f4b71Sopenharmony_ci
1105e41f4b71Sopenharmony_cidetach(): Promise&lt;void&gt;
1106e41f4b71Sopenharmony_ci
1107e41f4b71Sopenharmony_ciDetaches the self-drawing component from the input method. This API uses a promise to return the result.
1108e41f4b71Sopenharmony_ci
1109e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1110e41f4b71Sopenharmony_ci
1111e41f4b71Sopenharmony_ci**Return value**
1112e41f4b71Sopenharmony_ci
1113e41f4b71Sopenharmony_ci| Type| Description|
1114e41f4b71Sopenharmony_ci| -------- | -------- |
1115e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
1116e41f4b71Sopenharmony_ci
1117e41f4b71Sopenharmony_ci**Error codes**
1118e41f4b71Sopenharmony_ci
1119e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md).
1120e41f4b71Sopenharmony_ci
1121e41f4b71Sopenharmony_ci| ID| Error Message                            |
1122e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1123e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1124e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1125e41f4b71Sopenharmony_ci
1126e41f4b71Sopenharmony_ci**Example**
1127e41f4b71Sopenharmony_ci
1128e41f4b71Sopenharmony_ci```ts
1129e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1130e41f4b71Sopenharmony_ci
1131e41f4b71Sopenharmony_ciinputMethodController.detach().then(() => {
1132e41f4b71Sopenharmony_ci  console.log('Succeeded in detaching inputMethod.');
1133e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1134e41f4b71Sopenharmony_ci  console.error(`Failed to detach: ${JSON.stringify(err)}`);
1135e41f4b71Sopenharmony_ci});
1136e41f4b71Sopenharmony_ci```
1137e41f4b71Sopenharmony_ci
1138e41f4b71Sopenharmony_ci### setCallingWindow<sup>10+</sup>
1139e41f4b71Sopenharmony_ci
1140e41f4b71Sopenharmony_cisetCallingWindow(windowId: number, callback: AsyncCallback&lt;void&gt;): void
1141e41f4b71Sopenharmony_ci
1142e41f4b71Sopenharmony_ciSets the window to be avoided by the input method. This API uses an asynchronous callback to return the result.
1143e41f4b71Sopenharmony_ci
1144e41f4b71Sopenharmony_ci> **NOTE**
1145e41f4b71Sopenharmony_ci>
1146e41f4b71Sopenharmony_ci> After the window ID of the application bound to the input method is passed in the API, the input method window will not cover the window holding the application.
1147e41f4b71Sopenharmony_ci
1148e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1149e41f4b71Sopenharmony_ci
1150e41f4b71Sopenharmony_ci**Parameters**
1151e41f4b71Sopenharmony_ci
1152e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
1153e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1154e41f4b71Sopenharmony_ci| windowId | number | Yes| Window ID of the application bound to the input method.|
1155e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
1156e41f4b71Sopenharmony_ci
1157e41f4b71Sopenharmony_ci**Error codes**
1158e41f4b71Sopenharmony_ci
1159e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
1160e41f4b71Sopenharmony_ci
1161e41f4b71Sopenharmony_ci| ID| Error Message                            |
1162e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1163e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1164e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1165e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1166e41f4b71Sopenharmony_ci| 12800009 | input method client is detached.             |
1167e41f4b71Sopenharmony_ci
1168e41f4b71Sopenharmony_ci**Example**
1169e41f4b71Sopenharmony_ci
1170e41f4b71Sopenharmony_ci```ts
1171e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1172e41f4b71Sopenharmony_ci
1173e41f4b71Sopenharmony_citry {
1174e41f4b71Sopenharmony_ci  let windowId: number = 2000;
1175e41f4b71Sopenharmony_ci  inputMethodController.setCallingWindow(windowId, (err: BusinessError) => {
1176e41f4b71Sopenharmony_ci    if (err) {
1177e41f4b71Sopenharmony_ci      console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`);
1178e41f4b71Sopenharmony_ci      return;
1179e41f4b71Sopenharmony_ci    }
1180e41f4b71Sopenharmony_ci    console.log('Succeeded in setting callingWindow.');
1181e41f4b71Sopenharmony_ci  });
1182e41f4b71Sopenharmony_ci} catch(err) {
1183e41f4b71Sopenharmony_ci  console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`);
1184e41f4b71Sopenharmony_ci}
1185e41f4b71Sopenharmony_ci```
1186e41f4b71Sopenharmony_ci
1187e41f4b71Sopenharmony_ci### setCallingWindow<sup>10+</sup>
1188e41f4b71Sopenharmony_ci
1189e41f4b71Sopenharmony_cisetCallingWindow(windowId: number): Promise&lt;void&gt;
1190e41f4b71Sopenharmony_ci
1191e41f4b71Sopenharmony_ciSets the window to be avoided by the input method. This API uses a promise to return the result.
1192e41f4b71Sopenharmony_ci
1193e41f4b71Sopenharmony_ci> **NOTE**
1194e41f4b71Sopenharmony_ci>
1195e41f4b71Sopenharmony_ci> After the window ID of the application bound to the input method is passed in the API, the input method window will not cover the window holding the application.
1196e41f4b71Sopenharmony_ci
1197e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1198e41f4b71Sopenharmony_ci
1199e41f4b71Sopenharmony_ci**Parameters**
1200e41f4b71Sopenharmony_ci
1201e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
1202e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1203e41f4b71Sopenharmony_ci| windowId | number | Yes| Window ID of the application bound to the input method.|
1204e41f4b71Sopenharmony_ci
1205e41f4b71Sopenharmony_ci**Return value**
1206e41f4b71Sopenharmony_ci
1207e41f4b71Sopenharmony_ci| Type| Description|
1208e41f4b71Sopenharmony_ci| -------- | -------- |
1209e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
1210e41f4b71Sopenharmony_ci
1211e41f4b71Sopenharmony_ci**Error codes**
1212e41f4b71Sopenharmony_ci
1213e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
1214e41f4b71Sopenharmony_ci
1215e41f4b71Sopenharmony_ci| ID| Error Message                            |
1216e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1217e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1218e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1219e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1220e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
1221e41f4b71Sopenharmony_ci
1222e41f4b71Sopenharmony_ci**Example**
1223e41f4b71Sopenharmony_ci
1224e41f4b71Sopenharmony_ci```ts
1225e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1226e41f4b71Sopenharmony_ci
1227e41f4b71Sopenharmony_citry {
1228e41f4b71Sopenharmony_ci  let windowId: number = 2000;
1229e41f4b71Sopenharmony_ci  inputMethodController.setCallingWindow(windowId).then(() => {
1230e41f4b71Sopenharmony_ci    console.log('Succeeded in setting callingWindow.');
1231e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1232e41f4b71Sopenharmony_ci    console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`);
1233e41f4b71Sopenharmony_ci  })
1234e41f4b71Sopenharmony_ci} catch(err) {
1235e41f4b71Sopenharmony_ci  console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`);
1236e41f4b71Sopenharmony_ci}
1237e41f4b71Sopenharmony_ci```
1238e41f4b71Sopenharmony_ci
1239e41f4b71Sopenharmony_ci### updateCursor<sup>10+</sup>
1240e41f4b71Sopenharmony_ci
1241e41f4b71Sopenharmony_ciupdateCursor(cursorInfo: CursorInfo, callback: AsyncCallback&lt;void&gt;): void
1242e41f4b71Sopenharmony_ci
1243e41f4b71Sopenharmony_ciUpdates the cursor information in this edit box. This API can be called to notify the input method of the cursor changes. This API uses an asynchronous callback to return the result.
1244e41f4b71Sopenharmony_ci
1245e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1246e41f4b71Sopenharmony_ci
1247e41f4b71Sopenharmony_ci**Parameters**
1248e41f4b71Sopenharmony_ci
1249e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
1250e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1251e41f4b71Sopenharmony_ci| cursorInfo | [CursorInfo](#cursorinfo10) | Yes| Cursor information.|
1252e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
1253e41f4b71Sopenharmony_ci
1254e41f4b71Sopenharmony_ci**Error codes**
1255e41f4b71Sopenharmony_ci
1256e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
1257e41f4b71Sopenharmony_ci
1258e41f4b71Sopenharmony_ci| ID| Error Message                            |
1259e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1260e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
1261e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1262e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1263e41f4b71Sopenharmony_ci| 12800009 | input method client is detached.             |
1264e41f4b71Sopenharmony_ci
1265e41f4b71Sopenharmony_ci**Example**
1266e41f4b71Sopenharmony_ci
1267e41f4b71Sopenharmony_ci```ts
1268e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1269e41f4b71Sopenharmony_ci
1270e41f4b71Sopenharmony_citry {
1271e41f4b71Sopenharmony_ci  let cursorInfo: inputMethod.CursorInfo = { left: 0, top: 0, width: 600, height: 800 };
1272e41f4b71Sopenharmony_ci  inputMethodController.updateCursor(cursorInfo, (err: BusinessError) => {
1273e41f4b71Sopenharmony_ci    if (err) {
1274e41f4b71Sopenharmony_ci      console.error(`Failed to updateCursor: ${JSON.stringify(err)}`);
1275e41f4b71Sopenharmony_ci      return;
1276e41f4b71Sopenharmony_ci    }
1277e41f4b71Sopenharmony_ci    console.log('Succeeded in updating cursorInfo.');
1278e41f4b71Sopenharmony_ci  });
1279e41f4b71Sopenharmony_ci} catch(err) {
1280e41f4b71Sopenharmony_ci  console.error(`Failed to updateCursor: ${JSON.stringify(err)}`);
1281e41f4b71Sopenharmony_ci}
1282e41f4b71Sopenharmony_ci```
1283e41f4b71Sopenharmony_ci
1284e41f4b71Sopenharmony_ci### updateCursor<sup>10+</sup>
1285e41f4b71Sopenharmony_ci
1286e41f4b71Sopenharmony_ciupdateCursor(cursorInfo: CursorInfo): Promise&lt;void&gt;
1287e41f4b71Sopenharmony_ci
1288e41f4b71Sopenharmony_ciUpdates the cursor information in this edit box. This API can be called to notify the input method of the cursor changes. This API uses a promise to return the result.
1289e41f4b71Sopenharmony_ci
1290e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1291e41f4b71Sopenharmony_ci
1292e41f4b71Sopenharmony_ci**Parameters**
1293e41f4b71Sopenharmony_ci
1294e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
1295e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1296e41f4b71Sopenharmony_ci| cursorInfo | [CursorInfo](#cursorinfo10) | Yes| Cursor information.|
1297e41f4b71Sopenharmony_ci
1298e41f4b71Sopenharmony_ci**Return value**
1299e41f4b71Sopenharmony_ci
1300e41f4b71Sopenharmony_ci| Type| Description|
1301e41f4b71Sopenharmony_ci| -------- | -------- |
1302e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
1303e41f4b71Sopenharmony_ci
1304e41f4b71Sopenharmony_ci**Error codes**
1305e41f4b71Sopenharmony_ci
1306e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
1307e41f4b71Sopenharmony_ci
1308e41f4b71Sopenharmony_ci| ID| Error Message                            |
1309e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1310e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
1311e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1312e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1313e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
1314e41f4b71Sopenharmony_ci
1315e41f4b71Sopenharmony_ci**Example**
1316e41f4b71Sopenharmony_ci
1317e41f4b71Sopenharmony_ci```ts
1318e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1319e41f4b71Sopenharmony_ci
1320e41f4b71Sopenharmony_citry {
1321e41f4b71Sopenharmony_ci  let cursorInfo: inputMethod.CursorInfo = { left: 0, top: 0, width: 600, height: 800 };
1322e41f4b71Sopenharmony_ci  inputMethodController.updateCursor(cursorInfo).then(() => {
1323e41f4b71Sopenharmony_ci    console.log('Succeeded in updating cursorInfo.');
1324e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1325e41f4b71Sopenharmony_ci    console.error(`Failed to updateCursor: ${JSON.stringify(err)}`);
1326e41f4b71Sopenharmony_ci  })
1327e41f4b71Sopenharmony_ci} catch(err) {
1328e41f4b71Sopenharmony_ci  console.error(`Failed to updateCursor: ${JSON.stringify(err)}`);
1329e41f4b71Sopenharmony_ci}
1330e41f4b71Sopenharmony_ci```
1331e41f4b71Sopenharmony_ci
1332e41f4b71Sopenharmony_ci### changeSelection<sup>10+</sup>
1333e41f4b71Sopenharmony_ci
1334e41f4b71Sopenharmony_cichangeSelection(text: string, start: number, end: number, callback: AsyncCallback&lt;void&gt;): void
1335e41f4b71Sopenharmony_ci
1336e41f4b71Sopenharmony_ciUpdates the information about the selected text in this edit box, to notify the input method when the selected text content or text range changes. This API uses an asynchronous callback to return the result.
1337e41f4b71Sopenharmony_ci
1338e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1339e41f4b71Sopenharmony_ci
1340e41f4b71Sopenharmony_ci**Parameters**
1341e41f4b71Sopenharmony_ci
1342e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
1343e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1344e41f4b71Sopenharmony_ci| text | string | Yes| All input text.|
1345e41f4b71Sopenharmony_ci| start | number | Yes| Start position of the selected text.|
1346e41f4b71Sopenharmony_ci| end | number | Yes| End position of the selected text.|
1347e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
1348e41f4b71Sopenharmony_ci
1349e41f4b71Sopenharmony_ci**Error codes**
1350e41f4b71Sopenharmony_ci
1351e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
1352e41f4b71Sopenharmony_ci
1353e41f4b71Sopenharmony_ci| ID| Error Message                            |
1354e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1355e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1356e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1357e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1358e41f4b71Sopenharmony_ci| 12800009 | input method client is detached.             |
1359e41f4b71Sopenharmony_ci
1360e41f4b71Sopenharmony_ci**Example**
1361e41f4b71Sopenharmony_ci
1362e41f4b71Sopenharmony_ci```ts
1363e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1364e41f4b71Sopenharmony_ci
1365e41f4b71Sopenharmony_citry {
1366e41f4b71Sopenharmony_ci  inputMethodController.changeSelection('text', 0, 5, (err: BusinessError) => {
1367e41f4b71Sopenharmony_ci    if (err) {
1368e41f4b71Sopenharmony_ci      console.error(`Failed to changeSelection: ${JSON.stringify(err)}`);
1369e41f4b71Sopenharmony_ci      return;
1370e41f4b71Sopenharmony_ci    }
1371e41f4b71Sopenharmony_ci    console.log('Succeeded in changing selection.');
1372e41f4b71Sopenharmony_ci  });
1373e41f4b71Sopenharmony_ci} catch(err) {
1374e41f4b71Sopenharmony_ci  console.error(`Failed to changeSelection: ${JSON.stringify(err)}`);
1375e41f4b71Sopenharmony_ci}
1376e41f4b71Sopenharmony_ci```
1377e41f4b71Sopenharmony_ci
1378e41f4b71Sopenharmony_ci### changeSelection<sup>10+</sup>
1379e41f4b71Sopenharmony_ci
1380e41f4b71Sopenharmony_cichangeSelection(text: string, start: number, end: number): Promise&lt;void&gt;
1381e41f4b71Sopenharmony_ci
1382e41f4b71Sopenharmony_ciUpdates the information about the selected text in this edit box, to notify the input method when the selected text content or text range changes. This API uses a promise to return the result.
1383e41f4b71Sopenharmony_ci
1384e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1385e41f4b71Sopenharmony_ci
1386e41f4b71Sopenharmony_ci**Parameters**
1387e41f4b71Sopenharmony_ci
1388e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
1389e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1390e41f4b71Sopenharmony_ci| text | string | Yes| All input text.|
1391e41f4b71Sopenharmony_ci| start | number | Yes| Start position of the selected text.|
1392e41f4b71Sopenharmony_ci| end | number | Yes| End position of the selected text.|
1393e41f4b71Sopenharmony_ci
1394e41f4b71Sopenharmony_ci**Return value**
1395e41f4b71Sopenharmony_ci
1396e41f4b71Sopenharmony_ci| Type| Description|
1397e41f4b71Sopenharmony_ci| -------- | -------- |
1398e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
1399e41f4b71Sopenharmony_ci
1400e41f4b71Sopenharmony_ci**Error codes**
1401e41f4b71Sopenharmony_ci
1402e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
1403e41f4b71Sopenharmony_ci
1404e41f4b71Sopenharmony_ci| ID| Error Message                            |
1405e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1406e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1407e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1408e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1409e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
1410e41f4b71Sopenharmony_ci
1411e41f4b71Sopenharmony_ci**Example**
1412e41f4b71Sopenharmony_ci
1413e41f4b71Sopenharmony_ci```ts
1414e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1415e41f4b71Sopenharmony_ci
1416e41f4b71Sopenharmony_citry {
1417e41f4b71Sopenharmony_ci  inputMethodController.changeSelection('test', 0, 5).then(() => {
1418e41f4b71Sopenharmony_ci    console.log('Succeeded in changing selection.');
1419e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1420e41f4b71Sopenharmony_ci    console.error(`Failed to changeSelection: ${JSON.stringify(err)}`);
1421e41f4b71Sopenharmony_ci  })
1422e41f4b71Sopenharmony_ci} catch(err) {
1423e41f4b71Sopenharmony_ci  console.error(`Failed to changeSelection: ${JSON.stringify(err)}`);
1424e41f4b71Sopenharmony_ci}
1425e41f4b71Sopenharmony_ci```
1426e41f4b71Sopenharmony_ci
1427e41f4b71Sopenharmony_ci### updateAttribute<sup>10+</sup>
1428e41f4b71Sopenharmony_ci
1429e41f4b71Sopenharmony_ciupdateAttribute(attribute: InputAttribute, callback: AsyncCallback&lt;void&gt;): void
1430e41f4b71Sopenharmony_ci
1431e41f4b71Sopenharmony_ciUpdates the attribute information of this edit box. This API uses an asynchronous callback to return the result.
1432e41f4b71Sopenharmony_ci
1433e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1434e41f4b71Sopenharmony_ci
1435e41f4b71Sopenharmony_ci**Parameters**
1436e41f4b71Sopenharmony_ci
1437e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
1438e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1439e41f4b71Sopenharmony_ci| attribute | [InputAttribute](#inputattribute10) | Yes| Attribute information.|
1440e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
1441e41f4b71Sopenharmony_ci
1442e41f4b71Sopenharmony_ci**Error codes**
1443e41f4b71Sopenharmony_ci
1444e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
1445e41f4b71Sopenharmony_ci
1446e41f4b71Sopenharmony_ci| ID| Error Message                            |
1447e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1448e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1449e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1450e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1451e41f4b71Sopenharmony_ci| 12800009 | input method client is detached.             |
1452e41f4b71Sopenharmony_ci
1453e41f4b71Sopenharmony_ci**Example**
1454e41f4b71Sopenharmony_ci
1455e41f4b71Sopenharmony_ci```ts
1456e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1457e41f4b71Sopenharmony_ci
1458e41f4b71Sopenharmony_citry {
1459e41f4b71Sopenharmony_ci  let inputAttribute: inputMethod.InputAttribute = { textInputType: 0, enterKeyType: 1 };
1460e41f4b71Sopenharmony_ci  inputMethodController.updateAttribute(inputAttribute, (err: BusinessError) => {
1461e41f4b71Sopenharmony_ci    if (err) {
1462e41f4b71Sopenharmony_ci      console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`);
1463e41f4b71Sopenharmony_ci      return;
1464e41f4b71Sopenharmony_ci    }
1465e41f4b71Sopenharmony_ci    console.log('Succeeded in updating attribute.');
1466e41f4b71Sopenharmony_ci  });
1467e41f4b71Sopenharmony_ci} catch(err) {
1468e41f4b71Sopenharmony_ci  console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`);
1469e41f4b71Sopenharmony_ci}
1470e41f4b71Sopenharmony_ci```
1471e41f4b71Sopenharmony_ci
1472e41f4b71Sopenharmony_ci### updateAttribute<sup>10+</sup>
1473e41f4b71Sopenharmony_ci
1474e41f4b71Sopenharmony_ciupdateAttribute(attribute: InputAttribute): Promise&lt;void&gt;
1475e41f4b71Sopenharmony_ci
1476e41f4b71Sopenharmony_ciUpdates the attribute information of this edit box. This API uses a promise to return the result.
1477e41f4b71Sopenharmony_ci
1478e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1479e41f4b71Sopenharmony_ci
1480e41f4b71Sopenharmony_ci**Parameters**
1481e41f4b71Sopenharmony_ci
1482e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
1483e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1484e41f4b71Sopenharmony_ci| attribute | [InputAttribute](#inputattribute10) | Yes|  Attribute information.|
1485e41f4b71Sopenharmony_ci
1486e41f4b71Sopenharmony_ci**Return value**
1487e41f4b71Sopenharmony_ci
1488e41f4b71Sopenharmony_ci| Type| Description|
1489e41f4b71Sopenharmony_ci| -------- | -------- |
1490e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
1491e41f4b71Sopenharmony_ci
1492e41f4b71Sopenharmony_ci**Error codes**
1493e41f4b71Sopenharmony_ci
1494e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
1495e41f4b71Sopenharmony_ci
1496e41f4b71Sopenharmony_ci| ID| Error Message                            |
1497e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1498e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1499e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1500e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1501e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
1502e41f4b71Sopenharmony_ci
1503e41f4b71Sopenharmony_ci**Example**
1504e41f4b71Sopenharmony_ci
1505e41f4b71Sopenharmony_ci```ts
1506e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1507e41f4b71Sopenharmony_ci
1508e41f4b71Sopenharmony_citry {
1509e41f4b71Sopenharmony_ci  let inputAttribute: inputMethod.InputAttribute = { textInputType: 0, enterKeyType: 1 };
1510e41f4b71Sopenharmony_ci  inputMethodController.updateAttribute(inputAttribute).then(() => {
1511e41f4b71Sopenharmony_ci    console.log('Succeeded in updating attribute.');
1512e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1513e41f4b71Sopenharmony_ci    console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`);
1514e41f4b71Sopenharmony_ci  })
1515e41f4b71Sopenharmony_ci} catch(err) {
1516e41f4b71Sopenharmony_ci  console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`);
1517e41f4b71Sopenharmony_ci}
1518e41f4b71Sopenharmony_ci```
1519e41f4b71Sopenharmony_ci
1520e41f4b71Sopenharmony_ci### stopInputSession<sup>9+</sup>
1521e41f4b71Sopenharmony_ci
1522e41f4b71Sopenharmony_cistopInputSession(callback: AsyncCallback&lt;boolean&gt;): void
1523e41f4b71Sopenharmony_ci
1524e41f4b71Sopenharmony_ciEnds this input session. This API uses an asynchronous callback to return the result.
1525e41f4b71Sopenharmony_ci
1526e41f4b71Sopenharmony_ci> **NOTE**
1527e41f4b71Sopenharmony_ci>
1528e41f4b71Sopenharmony_ci> This API can be called only when the edit box is attached to the input method. That is, it can be called to end the input session only when the edit box is focused.
1529e41f4b71Sopenharmony_ci
1530e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1531e41f4b71Sopenharmony_ci
1532e41f4b71Sopenharmony_ci**Parameters**
1533e41f4b71Sopenharmony_ci
1534e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
1535e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1536e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
1537e41f4b71Sopenharmony_ci
1538e41f4b71Sopenharmony_ci**Error codes**
1539e41f4b71Sopenharmony_ci
1540e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md).
1541e41f4b71Sopenharmony_ci
1542e41f4b71Sopenharmony_ci| ID| Error Message                            |
1543e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1544e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1545e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1546e41f4b71Sopenharmony_ci
1547e41f4b71Sopenharmony_ci**Example**
1548e41f4b71Sopenharmony_ci
1549e41f4b71Sopenharmony_ci```ts
1550e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1551e41f4b71Sopenharmony_ci
1552e41f4b71Sopenharmony_citry {
1553e41f4b71Sopenharmony_ci  inputMethodController.stopInputSession((err: BusinessError, result: boolean) => {
1554e41f4b71Sopenharmony_ci    if (err) {
1555e41f4b71Sopenharmony_ci      console.error(`Failed to stopInputSession: ${JSON.stringify(err)}`);
1556e41f4b71Sopenharmony_ci      return;
1557e41f4b71Sopenharmony_ci    }
1558e41f4b71Sopenharmony_ci    if (result) {
1559e41f4b71Sopenharmony_ci      console.log('Succeeded in stopping inputSession.');
1560e41f4b71Sopenharmony_ci    } else {
1561e41f4b71Sopenharmony_ci      console.error('Failed to stopInputSession.');
1562e41f4b71Sopenharmony_ci    }
1563e41f4b71Sopenharmony_ci  });
1564e41f4b71Sopenharmony_ci} catch(err) {
1565e41f4b71Sopenharmony_ci  console.error(`Failed to stopInputSession: ${JSON.stringify(err)}`);
1566e41f4b71Sopenharmony_ci}
1567e41f4b71Sopenharmony_ci```
1568e41f4b71Sopenharmony_ci
1569e41f4b71Sopenharmony_ci### stopInputSession<sup>9+</sup>
1570e41f4b71Sopenharmony_ci
1571e41f4b71Sopenharmony_cistopInputSession(): Promise&lt;boolean&gt;
1572e41f4b71Sopenharmony_ci
1573e41f4b71Sopenharmony_ciEnds this input session. This API uses a promise to return the result.
1574e41f4b71Sopenharmony_ci
1575e41f4b71Sopenharmony_ci> **NOTE**
1576e41f4b71Sopenharmony_ci>
1577e41f4b71Sopenharmony_ci> This API can be called only when the edit box is attached to the input method. That is, it can be called to end the input session only when the edit box is focused.
1578e41f4b71Sopenharmony_ci
1579e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1580e41f4b71Sopenharmony_ci
1581e41f4b71Sopenharmony_ci**Return value**
1582e41f4b71Sopenharmony_ci
1583e41f4b71Sopenharmony_ci| Type| Description|
1584e41f4b71Sopenharmony_ci| -------- | -------- |
1585e41f4b71Sopenharmony_ci| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means that the operation is successful, and **false** means the opposite.|
1586e41f4b71Sopenharmony_ci
1587e41f4b71Sopenharmony_ci**Error codes**
1588e41f4b71Sopenharmony_ci
1589e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md).
1590e41f4b71Sopenharmony_ci
1591e41f4b71Sopenharmony_ci| ID| Error Message                            |
1592e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1593e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1594e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1595e41f4b71Sopenharmony_ci
1596e41f4b71Sopenharmony_ci**Example**
1597e41f4b71Sopenharmony_ci
1598e41f4b71Sopenharmony_ci```ts
1599e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1600e41f4b71Sopenharmony_ci
1601e41f4b71Sopenharmony_citry {
1602e41f4b71Sopenharmony_ci  inputMethodController.stopInputSession().then((result: boolean) => {
1603e41f4b71Sopenharmony_ci    if (result) {
1604e41f4b71Sopenharmony_ci      console.log('Succeeded in stopping inputSession.');
1605e41f4b71Sopenharmony_ci    } else {
1606e41f4b71Sopenharmony_ci      console.error('Failed to stopInputSession.');
1607e41f4b71Sopenharmony_ci    }
1608e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1609e41f4b71Sopenharmony_ci    console.error(`Failed to stopInputSession: ${JSON.stringify(err)}`);
1610e41f4b71Sopenharmony_ci  })
1611e41f4b71Sopenharmony_ci} catch(err) {
1612e41f4b71Sopenharmony_ci  console.error(`Failed to stopInputSession: ${JSON.stringify(err)}`);
1613e41f4b71Sopenharmony_ci}
1614e41f4b71Sopenharmony_ci```
1615e41f4b71Sopenharmony_ci
1616e41f4b71Sopenharmony_ci### showSoftKeyboard<sup>9+</sup>
1617e41f4b71Sopenharmony_ci
1618e41f4b71Sopenharmony_cishowSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
1619e41f4b71Sopenharmony_ci
1620e41f4b71Sopenharmony_ciShows the soft keyboard. This API uses an asynchronous callback to return the result.
1621e41f4b71Sopenharmony_ci
1622e41f4b71Sopenharmony_ci> **NOTE**
1623e41f4b71Sopenharmony_ci>
1624e41f4b71Sopenharmony_ci> This API can be called only when the edit box is attached to the input method. That is, it can be called to show the soft keyboard only when the edit box is focused.
1625e41f4b71Sopenharmony_ci
1626e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.CONNECT_IME_ABILITY (for system applications only)
1627e41f4b71Sopenharmony_ci
1628e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1629e41f4b71Sopenharmony_ci
1630e41f4b71Sopenharmony_ci**Parameters**
1631e41f4b71Sopenharmony_ci
1632e41f4b71Sopenharmony_ci| Name  | Type                 | Mandatory| Description      |
1633e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
1634e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
1635e41f4b71Sopenharmony_ci
1636e41f4b71Sopenharmony_ci**Error codes**
1637e41f4b71Sopenharmony_ci
1638e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
1639e41f4b71Sopenharmony_ci
1640e41f4b71Sopenharmony_ci| ID| Error Message                            |
1641e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1642e41f4b71Sopenharmony_ci| 201      | permissions check fails.  |
1643e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1644e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1645e41f4b71Sopenharmony_ci
1646e41f4b71Sopenharmony_ci**Example**
1647e41f4b71Sopenharmony_ci
1648e41f4b71Sopenharmony_ci```ts
1649e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1650e41f4b71Sopenharmony_ci
1651e41f4b71Sopenharmony_ciinputMethodController.showSoftKeyboard((err: BusinessError) => {
1652e41f4b71Sopenharmony_ci  if (!err) {
1653e41f4b71Sopenharmony_ci    console.log('Succeeded in showing softKeyboard.');
1654e41f4b71Sopenharmony_ci  } else {
1655e41f4b71Sopenharmony_ci    console.error(`Failed to show softKeyboard: ${JSON.stringify(err)}`);
1656e41f4b71Sopenharmony_ci  }
1657e41f4b71Sopenharmony_ci})
1658e41f4b71Sopenharmony_ci```
1659e41f4b71Sopenharmony_ci
1660e41f4b71Sopenharmony_ci### showSoftKeyboard<sup>9+</sup>
1661e41f4b71Sopenharmony_ci
1662e41f4b71Sopenharmony_cishowSoftKeyboard(): Promise&lt;void&gt;
1663e41f4b71Sopenharmony_ci
1664e41f4b71Sopenharmony_ciShows the soft keyboard. This API uses a promise to return the result.
1665e41f4b71Sopenharmony_ci
1666e41f4b71Sopenharmony_ci> **NOTE**
1667e41f4b71Sopenharmony_ci>
1668e41f4b71Sopenharmony_ci> This API can be called only when the edit box is attached to the input method. That is, it can be called to show the soft keyboard only when the edit box is focused.
1669e41f4b71Sopenharmony_ci
1670e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.CONNECT_IME_ABILITY (for system applications only)
1671e41f4b71Sopenharmony_ci
1672e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1673e41f4b71Sopenharmony_ci
1674e41f4b71Sopenharmony_ci**Return value**
1675e41f4b71Sopenharmony_ci
1676e41f4b71Sopenharmony_ci| Type               | Description                     |
1677e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
1678e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
1679e41f4b71Sopenharmony_ci
1680e41f4b71Sopenharmony_ci**Error codes**
1681e41f4b71Sopenharmony_ci
1682e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
1683e41f4b71Sopenharmony_ci
1684e41f4b71Sopenharmony_ci| ID| Error Message                            |
1685e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1686e41f4b71Sopenharmony_ci| 201      | permissions check fails.  |
1687e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1688e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1689e41f4b71Sopenharmony_ci
1690e41f4b71Sopenharmony_ci**Example**
1691e41f4b71Sopenharmony_ci
1692e41f4b71Sopenharmony_ci```ts
1693e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1694e41f4b71Sopenharmony_ci
1695e41f4b71Sopenharmony_ciinputMethodController.showSoftKeyboard().then(() => {
1696e41f4b71Sopenharmony_ci  console.log('Succeeded in showing softKeyboard.');
1697e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1698e41f4b71Sopenharmony_ci  console.error(`Failed to show softKeyboard: ${JSON.stringify(err)}`);
1699e41f4b71Sopenharmony_ci});
1700e41f4b71Sopenharmony_ci```
1701e41f4b71Sopenharmony_ci
1702e41f4b71Sopenharmony_ci### hideSoftKeyboard<sup>9+</sup>
1703e41f4b71Sopenharmony_ci
1704e41f4b71Sopenharmony_cihideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
1705e41f4b71Sopenharmony_ci
1706e41f4b71Sopenharmony_ciHides the soft keyboard. This API uses an asynchronous callback to return the result.
1707e41f4b71Sopenharmony_ci
1708e41f4b71Sopenharmony_ci> **NOTE**
1709e41f4b71Sopenharmony_ci>
1710e41f4b71Sopenharmony_ci> This API can be called only when the edit box is attached to the input method. That is, it can be called to hide the soft keyboard only when the edit box is focused.
1711e41f4b71Sopenharmony_ci
1712e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.CONNECT_IME_ABILITY (for system applications only)
1713e41f4b71Sopenharmony_ci
1714e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1715e41f4b71Sopenharmony_ci
1716e41f4b71Sopenharmony_ci**Parameters**
1717e41f4b71Sopenharmony_ci
1718e41f4b71Sopenharmony_ci| Name  | Type                 | Mandatory| Description      |
1719e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
1720e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
1721e41f4b71Sopenharmony_ci
1722e41f4b71Sopenharmony_ci**Error codes**
1723e41f4b71Sopenharmony_ci
1724e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
1725e41f4b71Sopenharmony_ci
1726e41f4b71Sopenharmony_ci| ID| Error Message                            |
1727e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1728e41f4b71Sopenharmony_ci| 201      | permissions check fails.  |
1729e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1730e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1731e41f4b71Sopenharmony_ci
1732e41f4b71Sopenharmony_ci**Example**
1733e41f4b71Sopenharmony_ci
1734e41f4b71Sopenharmony_ci```ts
1735e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1736e41f4b71Sopenharmony_ci
1737e41f4b71Sopenharmony_ciinputMethodController.hideSoftKeyboard((err: BusinessError) => {
1738e41f4b71Sopenharmony_ci  if (!err) {
1739e41f4b71Sopenharmony_ci    console.log('Succeeded in hiding softKeyboard.');
1740e41f4b71Sopenharmony_ci  } else {
1741e41f4b71Sopenharmony_ci    console.error(`Failed to hide softKeyboard: ${JSON.stringify(err)}`);
1742e41f4b71Sopenharmony_ci  }
1743e41f4b71Sopenharmony_ci})
1744e41f4b71Sopenharmony_ci```
1745e41f4b71Sopenharmony_ci
1746e41f4b71Sopenharmony_ci### hideSoftKeyboard<sup>9+</sup>
1747e41f4b71Sopenharmony_ci
1748e41f4b71Sopenharmony_cihideSoftKeyboard(): Promise&lt;void&gt;
1749e41f4b71Sopenharmony_ci
1750e41f4b71Sopenharmony_ciHides the soft keyboard. This API uses a promise to return the result.
1751e41f4b71Sopenharmony_ci
1752e41f4b71Sopenharmony_ci> **NOTE**
1753e41f4b71Sopenharmony_ci>
1754e41f4b71Sopenharmony_ci> This API can be called only when the edit box is attached to the input method. That is, it can be called to hide the soft keyboard only when the edit box is focused.
1755e41f4b71Sopenharmony_ci
1756e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.CONNECT_IME_ABILITY (for system applications only)
1757e41f4b71Sopenharmony_ci
1758e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1759e41f4b71Sopenharmony_ci
1760e41f4b71Sopenharmony_ci**Return value**
1761e41f4b71Sopenharmony_ci
1762e41f4b71Sopenharmony_ci| Type               | Description                     |
1763e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
1764e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
1765e41f4b71Sopenharmony_ci
1766e41f4b71Sopenharmony_ci**Error codes**
1767e41f4b71Sopenharmony_ci
1768e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
1769e41f4b71Sopenharmony_ci
1770e41f4b71Sopenharmony_ci| ID| Error Message                            |
1771e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1772e41f4b71Sopenharmony_ci| 201      | permissions check fails.  |
1773e41f4b71Sopenharmony_ci| 12800003 | input method client error.             |
1774e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
1775e41f4b71Sopenharmony_ci
1776e41f4b71Sopenharmony_ci**Example**
1777e41f4b71Sopenharmony_ci
1778e41f4b71Sopenharmony_ci```ts
1779e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1780e41f4b71Sopenharmony_ci
1781e41f4b71Sopenharmony_ciinputMethodController.hideSoftKeyboard().then(() => {
1782e41f4b71Sopenharmony_ci  console.log('Succeeded in hiding softKeyboard.');
1783e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1784e41f4b71Sopenharmony_ci  console.error(`Failed to hide softKeyboard: ${JSON.stringify(err)}`);
1785e41f4b71Sopenharmony_ci});
1786e41f4b71Sopenharmony_ci```
1787e41f4b71Sopenharmony_ci
1788e41f4b71Sopenharmony_ci### stopInput<sup>(deprecated)</sup>
1789e41f4b71Sopenharmony_ci
1790e41f4b71Sopenharmony_cistopInput(callback: AsyncCallback&lt;boolean&gt;): void
1791e41f4b71Sopenharmony_ci
1792e41f4b71Sopenharmony_ciEnds this input session. This API uses an asynchronous callback to return the result.
1793e41f4b71Sopenharmony_ci
1794e41f4b71Sopenharmony_ci> **NOTE**
1795e41f4b71Sopenharmony_ci> 
1796e41f4b71Sopenharmony_ci> This API can be called only when the edit box is attached to the input method. That is, it can be called to end the input session only when the edit box is focused.
1797e41f4b71Sopenharmony_ci> 
1798e41f4b71Sopenharmony_ci> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [stopInputSession()](#stopinputsession9) instead.
1799e41f4b71Sopenharmony_ci
1800e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1801e41f4b71Sopenharmony_ci
1802e41f4b71Sopenharmony_ci**Parameters**
1803e41f4b71Sopenharmony_ci
1804e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
1805e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1806e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
1807e41f4b71Sopenharmony_ci
1808e41f4b71Sopenharmony_ci**Example**
1809e41f4b71Sopenharmony_ci
1810e41f4b71Sopenharmony_ci```ts
1811e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1812e41f4b71Sopenharmony_ci
1813e41f4b71Sopenharmony_ciinputMethodController.stopInput((err: BusinessError, result: boolean) => {
1814e41f4b71Sopenharmony_ci  if (err) {
1815e41f4b71Sopenharmony_ci    console.error(`Failed to stopInput: ${JSON.stringify(err)}`);
1816e41f4b71Sopenharmony_ci    return;
1817e41f4b71Sopenharmony_ci  }
1818e41f4b71Sopenharmony_ci  if (result) {
1819e41f4b71Sopenharmony_ci    console.log('Succeeded in stopping input.');
1820e41f4b71Sopenharmony_ci  } else {
1821e41f4b71Sopenharmony_ci    console.error('Failed to stopInput.');
1822e41f4b71Sopenharmony_ci  }
1823e41f4b71Sopenharmony_ci});
1824e41f4b71Sopenharmony_ci```
1825e41f4b71Sopenharmony_ci
1826e41f4b71Sopenharmony_ci### stopInput<sup>(deprecated)</sup>
1827e41f4b71Sopenharmony_ci
1828e41f4b71Sopenharmony_cistopInput(): Promise&lt;boolean&gt;
1829e41f4b71Sopenharmony_ci
1830e41f4b71Sopenharmony_ciEnds this input session. This API uses a promise to return the result.
1831e41f4b71Sopenharmony_ci
1832e41f4b71Sopenharmony_ci> **NOTE**
1833e41f4b71Sopenharmony_ci> 
1834e41f4b71Sopenharmony_ci> This API can be called only when the edit box is attached to the input method. That is, it can be called to end the input session only when the edit box is focused.
1835e41f4b71Sopenharmony_ci> 
1836e41f4b71Sopenharmony_ci> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [stopInputSession()](#stopinputsession9) instead.
1837e41f4b71Sopenharmony_ci
1838e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1839e41f4b71Sopenharmony_ci
1840e41f4b71Sopenharmony_ci**Return value**
1841e41f4b71Sopenharmony_ci
1842e41f4b71Sopenharmony_ci| Type| Description|
1843e41f4b71Sopenharmony_ci| -------- | -------- |
1844e41f4b71Sopenharmony_ci| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means that the operation is successful, and **false** means the opposite.|
1845e41f4b71Sopenharmony_ci
1846e41f4b71Sopenharmony_ci**Example**
1847e41f4b71Sopenharmony_ci
1848e41f4b71Sopenharmony_ci```ts
1849e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1850e41f4b71Sopenharmony_ci
1851e41f4b71Sopenharmony_ciinputMethodController.stopInput().then((result: boolean) => {
1852e41f4b71Sopenharmony_ci  if (result) {
1853e41f4b71Sopenharmony_ci    console.log('Succeeded in stopping input.');
1854e41f4b71Sopenharmony_ci  } else {
1855e41f4b71Sopenharmony_ci    console.error('Failed to stopInput.');
1856e41f4b71Sopenharmony_ci  }
1857e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1858e41f4b71Sopenharmony_ci  console.error(`Failed to stopInput: ${JSON.stringify(err)}`);
1859e41f4b71Sopenharmony_ci})
1860e41f4b71Sopenharmony_ci```
1861e41f4b71Sopenharmony_ci
1862e41f4b71Sopenharmony_ci### on('insertText')<sup>10+</sup>
1863e41f4b71Sopenharmony_ci
1864e41f4b71Sopenharmony_cion(type: 'insertText', callback: (text: string) => void): void
1865e41f4b71Sopenharmony_ci
1866e41f4b71Sopenharmony_ciEnables listening for the text insertion event of the input method. This API uses an asynchronous callback to return the result.
1867e41f4b71Sopenharmony_ci
1868e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1869e41f4b71Sopenharmony_ci
1870e41f4b71Sopenharmony_ci**Parameters**
1871e41f4b71Sopenharmony_ci
1872e41f4b71Sopenharmony_ci| Name  | Type                                                        | Mandatory| Description                                                        |
1873e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
1874e41f4b71Sopenharmony_ci| type     | string                                                       | Yes  | Listening type. The value is fixed at **'insertText'**.|
1875e41f4b71Sopenharmony_ci| callback | (text: string) => void | Yes  | Callback used to return the text to be inserted.<br>The application needs to operate the content in the edit box based on the text content returned in the callback.|
1876e41f4b71Sopenharmony_ci
1877e41f4b71Sopenharmony_ci**Error codes**
1878e41f4b71Sopenharmony_ci
1879e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
1880e41f4b71Sopenharmony_ci
1881e41f4b71Sopenharmony_ci| ID| Error Message                            |
1882e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1883e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
1884e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
1885e41f4b71Sopenharmony_ci
1886e41f4b71Sopenharmony_ci**Example**
1887e41f4b71Sopenharmony_ci
1888e41f4b71Sopenharmony_ci```ts
1889e41f4b71Sopenharmony_cifunction callback1(text: string) {
1890e41f4b71Sopenharmony_ci  console.info('Succeeded in getting callback1 data: ' + JSON.stringify(text));
1891e41f4b71Sopenharmony_ci}
1892e41f4b71Sopenharmony_ci
1893e41f4b71Sopenharmony_cifunction callback2(text: string) {
1894e41f4b71Sopenharmony_ci  console.info('Succeeded in getting callback2 data: ' + JSON.stringify(text));
1895e41f4b71Sopenharmony_ci}
1896e41f4b71Sopenharmony_ci
1897e41f4b71Sopenharmony_citry {
1898e41f4b71Sopenharmony_ci  inputMethodController.on('insertText', callback1);
1899e41f4b71Sopenharmony_ci  inputMethodController.on('insertText', callback2);
1900e41f4b71Sopenharmony_ci  // Cancel only callback1 of insertText.
1901e41f4b71Sopenharmony_ci  inputMethodController.off('insertText', callback1);
1902e41f4b71Sopenharmony_ci  // Cancel all callbacks of insertText.
1903e41f4b71Sopenharmony_ci  inputMethodController.off('insertText');
1904e41f4b71Sopenharmony_ci} catch(err) {
1905e41f4b71Sopenharmony_ci  console.error(`Failed to subscribe insertText: ${JSON.stringify(err)}`);
1906e41f4b71Sopenharmony_ci}
1907e41f4b71Sopenharmony_ci```
1908e41f4b71Sopenharmony_ci
1909e41f4b71Sopenharmony_ci### off('insertText')<sup>10+</sup>
1910e41f4b71Sopenharmony_ci
1911e41f4b71Sopenharmony_cioff(type: 'insertText', callback?: (text: string) => void): void
1912e41f4b71Sopenharmony_ci
1913e41f4b71Sopenharmony_ciDisables listening for the text insertion event of the input method.
1914e41f4b71Sopenharmony_ci
1915e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1916e41f4b71Sopenharmony_ci
1917e41f4b71Sopenharmony_ci**Parameters**
1918e41f4b71Sopenharmony_ci
1919e41f4b71Sopenharmony_ci| Name  | Type                  | Mandatory| Description                                                        |
1920e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
1921e41f4b71Sopenharmony_ci| type     | string                 | Yes  | Listening type. The value is fixed at **'insertText'**.|
1922e41f4b71Sopenharmony_ci| callback | (text: string) => void | No  | Callback used for disable listening, which must be the same as that passed by the **on** API.<br>If this parameter is not specified, listening will be disabled for all callbacks corresponding to the specified type.|
1923e41f4b71Sopenharmony_ci
1924e41f4b71Sopenharmony_ci**Example**
1925e41f4b71Sopenharmony_ci
1926e41f4b71Sopenharmony_ci```ts
1927e41f4b71Sopenharmony_cilet onInsertTextCallback = (text: string) => {
1928e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing insertText: ${text}`);
1929e41f4b71Sopenharmony_ci};
1930e41f4b71Sopenharmony_ciinputMethodController.off('insertText', onInsertTextCallback);
1931e41f4b71Sopenharmony_ciinputMethodController.off('insertText');
1932e41f4b71Sopenharmony_ci```
1933e41f4b71Sopenharmony_ci
1934e41f4b71Sopenharmony_ci### on('deleteLeft')<sup>10+</sup>
1935e41f4b71Sopenharmony_ci
1936e41f4b71Sopenharmony_cion(type: 'deleteLeft', callback: (length: number) => void): void
1937e41f4b71Sopenharmony_ci
1938e41f4b71Sopenharmony_ciEnables listening for the leftward delete event. This API uses an asynchronous callback to return the result.
1939e41f4b71Sopenharmony_ci
1940e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1941e41f4b71Sopenharmony_ci
1942e41f4b71Sopenharmony_ci**Parameters**
1943e41f4b71Sopenharmony_ci
1944e41f4b71Sopenharmony_ci| Name  | Type| Mandatory| Description|
1945e41f4b71Sopenharmony_ci| -------- | ----- | ---- | ----- |
1946e41f4b71Sopenharmony_ci| type     | string  | Yes  | Listening type. The value is fixed at **'deleteLeft'**.|
1947e41f4b71Sopenharmony_ci| callback | (length: number) => void | Yes  | Callback used to return the length of the text to be deleted leftward.<br>The application needs to operate the content in the edit box based on the length returned in the callback.|
1948e41f4b71Sopenharmony_ci
1949e41f4b71Sopenharmony_ci**Error codes**
1950e41f4b71Sopenharmony_ci
1951e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
1952e41f4b71Sopenharmony_ci
1953e41f4b71Sopenharmony_ci| ID| Error Message                            |
1954e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
1955e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
1956e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
1957e41f4b71Sopenharmony_ci
1958e41f4b71Sopenharmony_ci**Example**
1959e41f4b71Sopenharmony_ci
1960e41f4b71Sopenharmony_ci```ts
1961e41f4b71Sopenharmony_citry {
1962e41f4b71Sopenharmony_ci  inputMethodController.on('deleteLeft', (length: number) => {
1963e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing deleteLeft, length: ${length}`);
1964e41f4b71Sopenharmony_ci  });
1965e41f4b71Sopenharmony_ci} catch(err) {
1966e41f4b71Sopenharmony_ci  console.error(`Failed to subscribe deleteLeft: ${JSON.stringify(err)}`);
1967e41f4b71Sopenharmony_ci}
1968e41f4b71Sopenharmony_ci```
1969e41f4b71Sopenharmony_ci
1970e41f4b71Sopenharmony_ci### off('deleteLeft')<sup>10+</sup>
1971e41f4b71Sopenharmony_ci
1972e41f4b71Sopenharmony_cioff(type: 'deleteLeft', callback?: (length: number) => void): void
1973e41f4b71Sopenharmony_ci
1974e41f4b71Sopenharmony_ciDisables listening for the leftward delete event.
1975e41f4b71Sopenharmony_ci
1976e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
1977e41f4b71Sopenharmony_ci
1978e41f4b71Sopenharmony_ci**Parameters**
1979e41f4b71Sopenharmony_ci
1980e41f4b71Sopenharmony_ci| Name  | Type                    | Mandatory| Description                                                        |
1981e41f4b71Sopenharmony_ci| -------- | ------------------------ | ---- | ------------------------------------------------------------ |
1982e41f4b71Sopenharmony_ci| type     | string                   | Yes  | Listening type. The value is fixed at **'deleteLeft'**.|
1983e41f4b71Sopenharmony_ci| callback | (length: number) => void | No  | Callback used for disable listening, which must be the same as that passed by the **on** API.<br>If this parameter is not specified, listening will be disabled for all callbacks corresponding to the specified type.|
1984e41f4b71Sopenharmony_ci
1985e41f4b71Sopenharmony_ci**Example**
1986e41f4b71Sopenharmony_ci
1987e41f4b71Sopenharmony_ci```ts
1988e41f4b71Sopenharmony_cilet onDeleteLeftCallback = (length: number) => {
1989e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing deleteLeft, length: ${length}`);
1990e41f4b71Sopenharmony_ci};
1991e41f4b71Sopenharmony_ciinputMethodController.off('deleteLeft', onDeleteLeftCallback);
1992e41f4b71Sopenharmony_ciinputMethodController.off('deleteLeft');
1993e41f4b71Sopenharmony_ci```
1994e41f4b71Sopenharmony_ci
1995e41f4b71Sopenharmony_ci### on('deleteRight')<sup>10+</sup>
1996e41f4b71Sopenharmony_ci
1997e41f4b71Sopenharmony_cion(type: 'deleteRight', callback: (length: number) => void): void
1998e41f4b71Sopenharmony_ci
1999e41f4b71Sopenharmony_ciEnables listening for the rightward delete event. This API uses an asynchronous callback to return the result.
2000e41f4b71Sopenharmony_ci
2001e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2002e41f4b71Sopenharmony_ci
2003e41f4b71Sopenharmony_ci**Parameters**
2004e41f4b71Sopenharmony_ci
2005e41f4b71Sopenharmony_ci| Name  | Type| Mandatory| Description|
2006e41f4b71Sopenharmony_ci| -------- | ----- | ---- | ----- |
2007e41f4b71Sopenharmony_ci| type     | string  | Yes  | Listening type. The value is fixed at **'deleteRight'**.|
2008e41f4b71Sopenharmony_ci| callback | (length: number) => void | Yes  | Callback used to return the length of the text to be deleted rightward.<br>The application needs to operate the content in the edit box based on the length returned in the callback.|
2009e41f4b71Sopenharmony_ci
2010e41f4b71Sopenharmony_ci**Error codes**
2011e41f4b71Sopenharmony_ci
2012e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
2013e41f4b71Sopenharmony_ci
2014e41f4b71Sopenharmony_ci| ID| Error Message                            |
2015e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
2016e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
2017e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
2018e41f4b71Sopenharmony_ci
2019e41f4b71Sopenharmony_ci**Example**
2020e41f4b71Sopenharmony_ci
2021e41f4b71Sopenharmony_ci```ts
2022e41f4b71Sopenharmony_citry {
2023e41f4b71Sopenharmony_ci  inputMethodController.on('deleteRight', (length: number) => {
2024e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing deleteRight, length: ${length}`);
2025e41f4b71Sopenharmony_ci  });
2026e41f4b71Sopenharmony_ci} catch(err) {
2027e41f4b71Sopenharmony_ci  console.error(`Failed to subscribe deleteRight: ${JSON.stringify(err)}`);
2028e41f4b71Sopenharmony_ci}
2029e41f4b71Sopenharmony_ci```
2030e41f4b71Sopenharmony_ci
2031e41f4b71Sopenharmony_ci### off('deleteRight')<sup>10+</sup>
2032e41f4b71Sopenharmony_ci
2033e41f4b71Sopenharmony_cioff(type: 'deleteRight', callback?: (length: number) => void): void
2034e41f4b71Sopenharmony_ci
2035e41f4b71Sopenharmony_ciDisables listening for the rightward delete event.
2036e41f4b71Sopenharmony_ci
2037e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2038e41f4b71Sopenharmony_ci
2039e41f4b71Sopenharmony_ci**Parameters**
2040e41f4b71Sopenharmony_ci
2041e41f4b71Sopenharmony_ci| Name  | Type                    | Mandatory| Description                                                        |
2042e41f4b71Sopenharmony_ci| -------- | ------------------------ | ---- | ------------------------------------------------------------ |
2043e41f4b71Sopenharmony_ci| type     | string                   | Yes  | Listening type. The value is fixed at **'deleteRight'**.|
2044e41f4b71Sopenharmony_ci| callback | (length: number) => void | No  | Callback used for disable listening, which must be the same as that passed by the **on** API.<br>If this parameter is not specified, listening will be disabled for all callbacks corresponding to the specified type.|
2045e41f4b71Sopenharmony_ci
2046e41f4b71Sopenharmony_ci**Example**
2047e41f4b71Sopenharmony_ci
2048e41f4b71Sopenharmony_ci```ts
2049e41f4b71Sopenharmony_cilet onDeleteRightCallback = (length: number) => {
2050e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing deleteRight, length: ${length}`);
2051e41f4b71Sopenharmony_ci};
2052e41f4b71Sopenharmony_ciinputMethodController.off('deleteRight', onDeleteRightCallback);
2053e41f4b71Sopenharmony_ciinputMethodController.off('deleteRight');
2054e41f4b71Sopenharmony_ci```
2055e41f4b71Sopenharmony_ci
2056e41f4b71Sopenharmony_ci### on('sendKeyboardStatus')<sup>10+</sup>
2057e41f4b71Sopenharmony_ci
2058e41f4b71Sopenharmony_cion(type: 'sendKeyboardStatus', callback: (keyboardStatus: KeyboardStatus) => void): void
2059e41f4b71Sopenharmony_ci
2060e41f4b71Sopenharmony_ciEnables listening for the soft keyboard status event of the input method. This API uses an asynchronous callback to return the result.
2061e41f4b71Sopenharmony_ci
2062e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2063e41f4b71Sopenharmony_ci
2064e41f4b71Sopenharmony_ci**Parameters**
2065e41f4b71Sopenharmony_ci
2066e41f4b71Sopenharmony_ci| Name  | Type | Mandatory| Description   |
2067e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ---- |
2068e41f4b71Sopenharmony_ci| type     | string  | Yes  | Listening type. The value is fixed at **'sendKeyboardStatus'**.|
2069e41f4b71Sopenharmony_ci| callback | (keyboardStatus: [KeyboardStatus](#keyboardstatus10)) => void | Yes  | Callback used to return the soft keyboard status.<br>The application needs to perform operations based on the soft keyboard state returned in the callback.|
2070e41f4b71Sopenharmony_ci
2071e41f4b71Sopenharmony_ci**Error codes**
2072e41f4b71Sopenharmony_ci
2073e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
2074e41f4b71Sopenharmony_ci
2075e41f4b71Sopenharmony_ci| ID| Error Message                            |
2076e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
2077e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
2078e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
2079e41f4b71Sopenharmony_ci
2080e41f4b71Sopenharmony_ci**Example**
2081e41f4b71Sopenharmony_ci
2082e41f4b71Sopenharmony_ci```ts
2083e41f4b71Sopenharmony_citry {
2084e41f4b71Sopenharmony_ci  inputMethodController.on('sendKeyboardStatus', (keyboardStatus: inputMethod.KeyboardStatus) => {
2085e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing sendKeyboardStatus, keyboardStatus: ${keyboardStatus}`);
2086e41f4b71Sopenharmony_ci  });
2087e41f4b71Sopenharmony_ci} catch(err) {
2088e41f4b71Sopenharmony_ci  console.error(`Failed to subscribe sendKeyboardStatus: ${JSON.stringify(err)}`);
2089e41f4b71Sopenharmony_ci}
2090e41f4b71Sopenharmony_ci```
2091e41f4b71Sopenharmony_ci
2092e41f4b71Sopenharmony_ci### off('sendKeyboardStatus')<sup>10+</sup>
2093e41f4b71Sopenharmony_ci
2094e41f4b71Sopenharmony_cioff(type: 'sendKeyboardStatus', callback?: (keyboardStatus: KeyboardStatus) => void): void
2095e41f4b71Sopenharmony_ci
2096e41f4b71Sopenharmony_ciDisables listening for the soft keyboard status event of the input method.
2097e41f4b71Sopenharmony_ci
2098e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2099e41f4b71Sopenharmony_ci
2100e41f4b71Sopenharmony_ci**Parameters**
2101e41f4b71Sopenharmony_ci
2102e41f4b71Sopenharmony_ci| Name  | Type                                                        | Mandatory| Description                                                        |
2103e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2104e41f4b71Sopenharmony_ci| type     | string                                                       | Yes  | Listening type. The value is fixed at **'sendKeyboardStatus'**.|
2105e41f4b71Sopenharmony_ci| callback | (keyboardStatus: [KeyboardStatus](#keyboardstatus10)) => void | No  | Callback used for disable listening. If this parameter is not specified, listening will be disabled for all callbacks corresponding to the specified type.|
2106e41f4b71Sopenharmony_ci
2107e41f4b71Sopenharmony_ci**Example**
2108e41f4b71Sopenharmony_ci
2109e41f4b71Sopenharmony_ci```ts
2110e41f4b71Sopenharmony_cilet onSendKeyboardStatus = (keyboardStatus: inputMethod.KeyboardStatus) => {
2111e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing sendKeyboardStatus, keyboardStatus: ${keyboardStatus}`);
2112e41f4b71Sopenharmony_ci};
2113e41f4b71Sopenharmony_ciinputMethodController.off('sendKeyboardStatus', onSendKeyboardStatus);
2114e41f4b71Sopenharmony_ciinputMethodController.off('sendKeyboardStatus');
2115e41f4b71Sopenharmony_ci```
2116e41f4b71Sopenharmony_ci
2117e41f4b71Sopenharmony_ci### on('sendFunctionKey')<sup>10+</sup>
2118e41f4b71Sopenharmony_ci
2119e41f4b71Sopenharmony_cion(type: 'sendFunctionKey', callback: (functionKey: FunctionKey) => void): void
2120e41f4b71Sopenharmony_ci
2121e41f4b71Sopenharmony_ciEnables listening for the function key sending event of the input method. This API uses an asynchronous callback to return the result.
2122e41f4b71Sopenharmony_ci
2123e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2124e41f4b71Sopenharmony_ci
2125e41f4b71Sopenharmony_ci**Parameters**
2126e41f4b71Sopenharmony_ci
2127e41f4b71Sopenharmony_ci| Name  | Type | Mandatory| Description    |
2128e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ----- |
2129e41f4b71Sopenharmony_ci| type     | string  | Yes  | Listening type. The value is fixed at **'sendFunctionKey'**.|
2130e41f4b71Sopenharmony_ci| callback | (functionKey: [FunctionKey](#functionkey10)) => void | Yes  | Callback used to return the function key information sent by the input method.<br>The application needs to perform operations based on the function key information returned in the callback.|
2131e41f4b71Sopenharmony_ci
2132e41f4b71Sopenharmony_ci**Error codes**
2133e41f4b71Sopenharmony_ci
2134e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
2135e41f4b71Sopenharmony_ci
2136e41f4b71Sopenharmony_ci| ID| Error Message                            |
2137e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
2138e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
2139e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
2140e41f4b71Sopenharmony_ci
2141e41f4b71Sopenharmony_ci**Example**
2142e41f4b71Sopenharmony_ci
2143e41f4b71Sopenharmony_ci```ts
2144e41f4b71Sopenharmony_citry {
2145e41f4b71Sopenharmony_ci  inputMethodController.on('sendFunctionKey', (functionKey: inputMethod.FunctionKey) => {
2146e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing sendFunctionKey, functionKey.enterKeyType: ${functionKey.enterKeyType}`);
2147e41f4b71Sopenharmony_ci  });
2148e41f4b71Sopenharmony_ci} catch(err) {
2149e41f4b71Sopenharmony_ci  console.error(`Failed to subscribe sendFunctionKey: ${JSON.stringify(err)}`);
2150e41f4b71Sopenharmony_ci}
2151e41f4b71Sopenharmony_ci```
2152e41f4b71Sopenharmony_ci
2153e41f4b71Sopenharmony_ci### off('sendFunctionKey')<sup>10+</sup>
2154e41f4b71Sopenharmony_ci
2155e41f4b71Sopenharmony_cioff(type: 'sendFunctionKey', callback?: (functionKey: FunctionKey) => void): void
2156e41f4b71Sopenharmony_ci
2157e41f4b71Sopenharmony_ciDisables listening for the function key sending event of the input method.
2158e41f4b71Sopenharmony_ci
2159e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2160e41f4b71Sopenharmony_ci
2161e41f4b71Sopenharmony_ci**Parameters**
2162e41f4b71Sopenharmony_ci
2163e41f4b71Sopenharmony_ci| Name  | Type                                                | Mandatory| Description                                                        |
2164e41f4b71Sopenharmony_ci| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
2165e41f4b71Sopenharmony_ci| type     | string                                               | Yes  | Listening type. The value is fixed at **'sendFunctionKey'**.|
2166e41f4b71Sopenharmony_ci| callback | (functionKey: [FunctionKey](#functionkey10)) => void | No  | Callback used for disable listening, which must be the same as that passed by the **on** API.<br>If this parameter is not specified, listening will be disabled for all callbacks corresponding to the specified type.|
2167e41f4b71Sopenharmony_ci
2168e41f4b71Sopenharmony_ci**Example**
2169e41f4b71Sopenharmony_ci
2170e41f4b71Sopenharmony_ci```ts
2171e41f4b71Sopenharmony_cilet onSendFunctionKey = (functionKey: inputMethod.FunctionKey) => {
2172e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing sendFunctionKey, functionKey: ${functionKey.enterKeyType}`);
2173e41f4b71Sopenharmony_ci};
2174e41f4b71Sopenharmony_ciinputMethodController.off('sendFunctionKey', onSendFunctionKey);
2175e41f4b71Sopenharmony_ciinputMethodController.off('sendFunctionKey');
2176e41f4b71Sopenharmony_ci```
2177e41f4b71Sopenharmony_ci
2178e41f4b71Sopenharmony_ci### on('moveCursor')<sup>10+</sup>
2179e41f4b71Sopenharmony_ci
2180e41f4b71Sopenharmony_cion(type: 'moveCursor', callback: (direction: Direction) => void): void
2181e41f4b71Sopenharmony_ci
2182e41f4b71Sopenharmony_ciEnables listening for the cursor movement event of the input method. This API uses an asynchronous callback to return the result.
2183e41f4b71Sopenharmony_ci
2184e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2185e41f4b71Sopenharmony_ci
2186e41f4b71Sopenharmony_ci**Parameters**
2187e41f4b71Sopenharmony_ci
2188e41f4b71Sopenharmony_ci| Name  | Type| Mandatory| Description  |
2189e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ------ |
2190e41f4b71Sopenharmony_ci| type     | string | Yes  | Listening type. The value is fixed at **'moveCursor'**.|
2191e41f4b71Sopenharmony_ci| callback | callback: (direction: [Direction<sup>10+</sup>](#direction10)) => void | Yes  | Callback used to return the cursor movement direction.<br>The application needs to change the cursor position based on the cursor movement direction returned in the callback. |
2192e41f4b71Sopenharmony_ci
2193e41f4b71Sopenharmony_ci**Error codes**
2194e41f4b71Sopenharmony_ci
2195e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
2196e41f4b71Sopenharmony_ci
2197e41f4b71Sopenharmony_ci| ID| Error Message                          |
2198e41f4b71Sopenharmony_ci| -------- | -------------------------------- |
2199e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
2200e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
2201e41f4b71Sopenharmony_ci
2202e41f4b71Sopenharmony_ci**Example**
2203e41f4b71Sopenharmony_ci
2204e41f4b71Sopenharmony_ci```ts
2205e41f4b71Sopenharmony_citry {
2206e41f4b71Sopenharmony_ci  inputMethodController.on('moveCursor', (direction: inputMethod.Direction) => {
2207e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing moveCursor, direction: ${direction}`);
2208e41f4b71Sopenharmony_ci  });
2209e41f4b71Sopenharmony_ci} catch(err) {
2210e41f4b71Sopenharmony_ci  console.error(`Failed to subscribe moveCursor: ${JSON.stringify(err)}`);
2211e41f4b71Sopenharmony_ci}
2212e41f4b71Sopenharmony_ci```
2213e41f4b71Sopenharmony_ci
2214e41f4b71Sopenharmony_ci### off('moveCursor')<sup>10+</sup>
2215e41f4b71Sopenharmony_ci
2216e41f4b71Sopenharmony_cioff(type: 'moveCursor', callback?: (direction: Direction) => void): void
2217e41f4b71Sopenharmony_ci
2218e41f4b71Sopenharmony_ciDisables listening for the cursor movement event of the input method.
2219e41f4b71Sopenharmony_ci
2220e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2221e41f4b71Sopenharmony_ci
2222e41f4b71Sopenharmony_ci**Parameters**
2223e41f4b71Sopenharmony_ci
2224e41f4b71Sopenharmony_ci| Name | Type   | Mandatory| Description |
2225e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---- |
2226e41f4b71Sopenharmony_ci| type   | string | Yes  | Listening type. The value is fixed at **'moveCursor'**.|
2227e41f4b71Sopenharmony_ci| callback | (direction: [Direction<sup>10+</sup>](#direction10)) => void | No| Callback used for disable listening, which must be the same as that passed by the **on** API.<br>If this parameter is not specified, listening will be disabled for all callbacks corresponding to the specified type.|
2228e41f4b71Sopenharmony_ci
2229e41f4b71Sopenharmony_ci**Example**
2230e41f4b71Sopenharmony_ci
2231e41f4b71Sopenharmony_ci```ts
2232e41f4b71Sopenharmony_cilet onMoveCursorCallback = (direction: inputMethod.Direction) => {
2233e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing moveCursor, direction: ${direction}`);
2234e41f4b71Sopenharmony_ci};
2235e41f4b71Sopenharmony_ciinputMethodController.off('moveCursor', onMoveCursorCallback);
2236e41f4b71Sopenharmony_ciinputMethodController.off('moveCursor');
2237e41f4b71Sopenharmony_ci```
2238e41f4b71Sopenharmony_ci
2239e41f4b71Sopenharmony_ci### on('handleExtendAction')<sup>10+</sup>
2240e41f4b71Sopenharmony_ci
2241e41f4b71Sopenharmony_cion(type: 'handleExtendAction', callback: (action: ExtendAction) => void): void
2242e41f4b71Sopenharmony_ci
2243e41f4b71Sopenharmony_ciEnables listening for the extended action handling event of the input method. This API uses an asynchronous callback to return the result.
2244e41f4b71Sopenharmony_ci
2245e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2246e41f4b71Sopenharmony_ci
2247e41f4b71Sopenharmony_ci**Parameters**
2248e41f4b71Sopenharmony_ci
2249e41f4b71Sopenharmony_ci| Name  | Type | Mandatory| Description  |
2250e41f4b71Sopenharmony_ci| -------- | ------ | ---- | -------- |
2251e41f4b71Sopenharmony_ci| type     | string    | Yes  | Listening type. The value is fixed at **'handleExtendAction'**.|
2252e41f4b71Sopenharmony_ci| callback | callback: (action: [ExtendAction](#extendaction10)) => void | Yes  | Callback used to return the extended action type.<br>The application needs to perform operations based on the extended action type returned in the callback.|
2253e41f4b71Sopenharmony_ci
2254e41f4b71Sopenharmony_ci**Error codes**
2255e41f4b71Sopenharmony_ci
2256e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
2257e41f4b71Sopenharmony_ci
2258e41f4b71Sopenharmony_ci| ID| Error Message                            |
2259e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
2260e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
2261e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
2262e41f4b71Sopenharmony_ci
2263e41f4b71Sopenharmony_ci**Example**
2264e41f4b71Sopenharmony_ci
2265e41f4b71Sopenharmony_ci```ts
2266e41f4b71Sopenharmony_citry {
2267e41f4b71Sopenharmony_ci  inputMethodController.on('handleExtendAction', (action: inputMethod.ExtendAction) => {
2268e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing handleExtendAction, action: ${action}`);
2269e41f4b71Sopenharmony_ci  });
2270e41f4b71Sopenharmony_ci} catch(err) {
2271e41f4b71Sopenharmony_ci  console.error(`Failed to subscribe handleExtendAction: ${JSON.stringify(err)}`);
2272e41f4b71Sopenharmony_ci}
2273e41f4b71Sopenharmony_ci```
2274e41f4b71Sopenharmony_ci
2275e41f4b71Sopenharmony_ci### off('handleExtendAction')<sup>10+</sup>
2276e41f4b71Sopenharmony_ci
2277e41f4b71Sopenharmony_cioff(type: 'handleExtendAction', callback?: (action: ExtendAction) => void): void
2278e41f4b71Sopenharmony_ci
2279e41f4b71Sopenharmony_ciDisables listening for the extended action handling event of the input method. This API uses an asynchronous callback to return the result.
2280e41f4b71Sopenharmony_ci
2281e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2282e41f4b71Sopenharmony_ci
2283e41f4b71Sopenharmony_ci**Parameters**
2284e41f4b71Sopenharmony_ci
2285e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description |
2286e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- |
2287e41f4b71Sopenharmony_ci| type   | string | Yes  | Listening type. The value is fixed at **'handleExtendAction'**.|
2288e41f4b71Sopenharmony_ci| callback | (action: [ExtendAction](#extendaction10)) => void | No| Callback used for disable listening, which must be the same as that passed by the **on** API.<br>If this parameter is not specified, listening will be disabled for all callbacks corresponding to the specified type.|
2289e41f4b71Sopenharmony_ci
2290e41f4b71Sopenharmony_ci**Example**
2291e41f4b71Sopenharmony_ci
2292e41f4b71Sopenharmony_ci```ts
2293e41f4b71Sopenharmony_citry {
2294e41f4b71Sopenharmony_ci  let onHandleExtendActionCallback = (action: inputMethod.ExtendAction) => {
2295e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing handleExtendAction, action: ${action}`);
2296e41f4b71Sopenharmony_ci  };
2297e41f4b71Sopenharmony_ci  inputMethodController.off('handleExtendAction', onHandleExtendActionCallback);
2298e41f4b71Sopenharmony_ci  inputMethodController.off('handleExtendAction');
2299e41f4b71Sopenharmony_ci} catch(err) {
2300e41f4b71Sopenharmony_ci  console.error(`Failed to subscribe handleExtendAction: ${JSON.stringify(err)}`);
2301e41f4b71Sopenharmony_ci}
2302e41f4b71Sopenharmony_ci```
2303e41f4b71Sopenharmony_ci
2304e41f4b71Sopenharmony_ci### on('selectByRange')<sup>10+</sup>
2305e41f4b71Sopenharmony_ci
2306e41f4b71Sopenharmony_cion(type: 'selectByRange', callback: Callback&lt;Range&gt;): void
2307e41f4b71Sopenharmony_ci
2308e41f4b71Sopenharmony_ciEnables listening for the select-by-range event. This API uses an asynchronous callback to return the result.
2309e41f4b71Sopenharmony_ci
2310e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2311e41f4b71Sopenharmony_ci
2312e41f4b71Sopenharmony_ci**Parameters**
2313e41f4b71Sopenharmony_ci
2314e41f4b71Sopenharmony_ci| Name  | Type    | Mandatory| Description    |
2315e41f4b71Sopenharmony_ci| -------- | ---- | ---- | ------- |
2316e41f4b71Sopenharmony_ci| type     | string  | Yes  | Listening type. The value is fixed at **'selectByRange'**.|
2317e41f4b71Sopenharmony_ci| callback | Callback&lt;[Range](#range10)&gt; | Yes  | Callback used to return the range of the text to be selected.<br>The application needs to select the text based on the range returned in the callback.|
2318e41f4b71Sopenharmony_ci
2319e41f4b71Sopenharmony_ci**Error codes**
2320e41f4b71Sopenharmony_ci
2321e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
2322e41f4b71Sopenharmony_ci
2323e41f4b71Sopenharmony_ci| ID| Error Message                                               |
2324e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------- |
2325e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
2326e41f4b71Sopenharmony_ci
2327e41f4b71Sopenharmony_ci**Example**
2328e41f4b71Sopenharmony_ci
2329e41f4b71Sopenharmony_ci```ts
2330e41f4b71Sopenharmony_citry {
2331e41f4b71Sopenharmony_ci  inputMethodController.on('selectByRange', (range: inputMethod.Range) => {
2332e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing selectByRange: start: ${range.start} , end: ${range.end}`);
2333e41f4b71Sopenharmony_ci  });
2334e41f4b71Sopenharmony_ci} catch(err) {
2335e41f4b71Sopenharmony_ci  console.error(`Failed to subscribe selectByRange: ${JSON.stringify(err)}`);
2336e41f4b71Sopenharmony_ci}
2337e41f4b71Sopenharmony_ci```
2338e41f4b71Sopenharmony_ci
2339e41f4b71Sopenharmony_ci### off('selectByRange')<sup>10+</sup>
2340e41f4b71Sopenharmony_ci
2341e41f4b71Sopenharmony_cioff(type: 'selectByRange', callback?:  Callback&lt;Range&gt;): void
2342e41f4b71Sopenharmony_ci
2343e41f4b71Sopenharmony_ciDisables listening for the select-by-range event. This API uses an asynchronous callback to return the result.
2344e41f4b71Sopenharmony_ci
2345e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2346e41f4b71Sopenharmony_ci
2347e41f4b71Sopenharmony_ci**Parameters**
2348e41f4b71Sopenharmony_ci
2349e41f4b71Sopenharmony_ci| Name  | Type                             | Mandatory| Description                                                        |
2350e41f4b71Sopenharmony_ci| -------- | --------------------------------- | ---- | ------------------------------------------------------------ |
2351e41f4b71Sopenharmony_ci| type     | string                            | Yes  | Listening type. The value is fixed at **'selectByRange'**.|
2352e41f4b71Sopenharmony_ci| callback | Callback&lt;[Range](#range10)&gt; | No  | Callback used for disable listening, which must be the same as that passed by the **on** API.<br>If this parameter is not specified, listening will be disabled for all callbacks corresponding to the specified type.|
2353e41f4b71Sopenharmony_ci
2354e41f4b71Sopenharmony_ci**Example**
2355e41f4b71Sopenharmony_ci
2356e41f4b71Sopenharmony_ci```ts
2357e41f4b71Sopenharmony_citry {
2358e41f4b71Sopenharmony_ci  let onSelectByRangeCallback = (range: inputMethod.Range) => {
2359e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing selectByRange, range: ${JSON.stringify(range)}`);
2360e41f4b71Sopenharmony_ci  };
2361e41f4b71Sopenharmony_ci  inputMethodController.off('selectByRange', onSelectByRangeCallback);
2362e41f4b71Sopenharmony_ci  inputMethodController.off('selectByRange');
2363e41f4b71Sopenharmony_ci} catch(err) {
2364e41f4b71Sopenharmony_ci  console.error(`Failed to subscribe selectByRange: ${JSON.stringify(err)}`);
2365e41f4b71Sopenharmony_ci}
2366e41f4b71Sopenharmony_ci```
2367e41f4b71Sopenharmony_ci
2368e41f4b71Sopenharmony_ci### on('selectByMovement')<sup>10+</sup>
2369e41f4b71Sopenharmony_ci
2370e41f4b71Sopenharmony_cion(type: 'selectByMovement', callback: Callback&lt;Movement&gt;): void
2371e41f4b71Sopenharmony_ci
2372e41f4b71Sopenharmony_ciEnables listening for the select-by-cursor-movement event. This API uses an asynchronous callback to return the result.
2373e41f4b71Sopenharmony_ci
2374e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2375e41f4b71Sopenharmony_ci
2376e41f4b71Sopenharmony_ci**Parameters**
2377e41f4b71Sopenharmony_ci
2378e41f4b71Sopenharmony_ci| Name  | Type  | Mandatory| Description    |
2379e41f4b71Sopenharmony_ci| -------- | ----- | ---- | ------ |
2380e41f4b71Sopenharmony_ci| type     | string  | Yes  | Listening type. The value is fixed at **'selectByMovement'**.|
2381e41f4b71Sopenharmony_ci| callback | Callback&lt;[Movement](#movement10)&gt; | Yes  | Callback used to return the direction in which the cursor moves.<br>The application needs to select the text based on the direction returned in the callback.|
2382e41f4b71Sopenharmony_ci
2383e41f4b71Sopenharmony_ci**Error codes**
2384e41f4b71Sopenharmony_ci
2385e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
2386e41f4b71Sopenharmony_ci
2387e41f4b71Sopenharmony_ci| ID| Error Message                                               |
2388e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------- |
2389e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
2390e41f4b71Sopenharmony_ci
2391e41f4b71Sopenharmony_ci**Example**
2392e41f4b71Sopenharmony_ci
2393e41f4b71Sopenharmony_ci```ts
2394e41f4b71Sopenharmony_citry {
2395e41f4b71Sopenharmony_ci  inputMethodController.on('selectByMovement', (movement: inputMethod.Movement) => {
2396e41f4b71Sopenharmony_ci    console.log('Succeeded in subscribing selectByMovement: direction: ' + movement.direction);
2397e41f4b71Sopenharmony_ci  });
2398e41f4b71Sopenharmony_ci} catch(err) {
2399e41f4b71Sopenharmony_ci  console.error(`Failed to subscribe selectByMovement: ${JSON.stringify(err)}`);
2400e41f4b71Sopenharmony_ci}
2401e41f4b71Sopenharmony_ci```
2402e41f4b71Sopenharmony_ci
2403e41f4b71Sopenharmony_ci### off('selectByMovement')<sup>10+</sup>
2404e41f4b71Sopenharmony_ci
2405e41f4b71Sopenharmony_cioff(type: 'selectByMovement', callback?: Callback&lt;Movement&gt;): void
2406e41f4b71Sopenharmony_ci
2407e41f4b71Sopenharmony_ciDisables listening for the select-by-cursor-movement event. This API uses an asynchronous callback to return the result.
2408e41f4b71Sopenharmony_ci
2409e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2410e41f4b71Sopenharmony_ci
2411e41f4b71Sopenharmony_ci**Parameters**
2412e41f4b71Sopenharmony_ci
2413e41f4b71Sopenharmony_ci| Name  | Type                                | Mandatory| Description                                                        |
2414e41f4b71Sopenharmony_ci| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
2415e41f4b71Sopenharmony_ci| type     | string                               | Yes  | Listening type. The value is fixed at **'selectByMovement'**.|
2416e41f4b71Sopenharmony_ci| callback | Callback&lt;[Movement](#movement10)> | No  | Callback used for disable listening, which must be the same as that passed by the **on** API.<br>If this parameter is not specified, listening will be disabled for all callbacks corresponding to the specified type.|
2417e41f4b71Sopenharmony_ci
2418e41f4b71Sopenharmony_ci**Example**
2419e41f4b71Sopenharmony_ci
2420e41f4b71Sopenharmony_ci```ts
2421e41f4b71Sopenharmony_citry {
2422e41f4b71Sopenharmony_ci  let onSelectByMovementCallback = (movement: inputMethod.Movement) => {
2423e41f4b71Sopenharmony_ci    console.log(`Succeeded in subscribing selectByMovement, movement.direction: ${movement.direction}`);
2424e41f4b71Sopenharmony_ci  };
2425e41f4b71Sopenharmony_ci  inputMethodController.off('selectByMovement', onSelectByMovementCallback);
2426e41f4b71Sopenharmony_ci  inputMethodController.off('selectByMovement');
2427e41f4b71Sopenharmony_ci} catch(err) {
2428e41f4b71Sopenharmony_ci  console.error(`Failed to unsubscribing selectByMovement: ${JSON.stringify(err)}`);
2429e41f4b71Sopenharmony_ci}
2430e41f4b71Sopenharmony_ci```
2431e41f4b71Sopenharmony_ci
2432e41f4b71Sopenharmony_ci### on('getLeftTextOfCursor')<sup>10+</sup>
2433e41f4b71Sopenharmony_ci
2434e41f4b71Sopenharmony_cion(type: 'getLeftTextOfCursor', callback: (length: number) => string): void
2435e41f4b71Sopenharmony_ci
2436e41f4b71Sopenharmony_ciEnables listening for the event of obtaining the length of text deleted leftward. This API uses an asynchronous callback to return the result.
2437e41f4b71Sopenharmony_ci
2438e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2439e41f4b71Sopenharmony_ci
2440e41f4b71Sopenharmony_ci**Parameters**
2441e41f4b71Sopenharmony_ci
2442e41f4b71Sopenharmony_ci| Name  | Type  | Mandatory| Description    |
2443e41f4b71Sopenharmony_ci| -------- | ----- | ---- | ------ |
2444e41f4b71Sopenharmony_ci| type     | string  | Yes  | Listening type. The value is fixed at **'getLeftTextOfCursor'**.|
2445e41f4b71Sopenharmony_ci| callback | (length: number) => string | Yes  | Callback used to obtain the text of the specified length deleted leftward.|
2446e41f4b71Sopenharmony_ci
2447e41f4b71Sopenharmony_ci**Error codes**
2448e41f4b71Sopenharmony_ci
2449e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
2450e41f4b71Sopenharmony_ci
2451e41f4b71Sopenharmony_ci| ID| Error Message                            |
2452e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
2453e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
2454e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
2455e41f4b71Sopenharmony_ci
2456e41f4b71Sopenharmony_ci**Example**
2457e41f4b71Sopenharmony_ci
2458e41f4b71Sopenharmony_ci```ts
2459e41f4b71Sopenharmony_citry {
2460e41f4b71Sopenharmony_ci  inputMethodController.on('getLeftTextOfCursor', (length: number) => {
2461e41f4b71Sopenharmony_ci    console.info(`Succeeded in subscribing getLeftTextOfCursor, length: ${length}`);
2462e41f4b71Sopenharmony_ci    let text:string = "";
2463e41f4b71Sopenharmony_ci    return text;
2464e41f4b71Sopenharmony_ci  });
2465e41f4b71Sopenharmony_ci} catch(err) {
2466e41f4b71Sopenharmony_ci  console.error(`Failed to unsubscribing getLeftTextOfCursor. err: ${JSON.stringify(err)}`);
2467e41f4b71Sopenharmony_ci}
2468e41f4b71Sopenharmony_ci```
2469e41f4b71Sopenharmony_ci
2470e41f4b71Sopenharmony_ci### off('getLeftTextOfCursor')<sup>10+</sup>
2471e41f4b71Sopenharmony_ci
2472e41f4b71Sopenharmony_cioff(type: 'getLeftTextOfCursor', callback?: (length: number) => string): void
2473e41f4b71Sopenharmony_ci
2474e41f4b71Sopenharmony_ciDisables listening for the event of obtaining the length of text deleted leftward. This API uses an asynchronous callback to return the result.
2475e41f4b71Sopenharmony_ci
2476e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2477e41f4b71Sopenharmony_ci
2478e41f4b71Sopenharmony_ci**Parameters**
2479e41f4b71Sopenharmony_ci
2480e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                                                        |
2481e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------------------------------------ |
2482e41f4b71Sopenharmony_ci| type   | string | Yes  | Listening type. The value is fixed at **'getLeftTextOfCursor'**.|
2483e41f4b71Sopenharmony_ci| callback | (length: number) => string | No | Callback used for disable listening, which must be the same as that passed by the **on** API.<br>If this parameter is not specified, listening will be disabled for all callbacks corresponding to the specified type.|
2484e41f4b71Sopenharmony_ci
2485e41f4b71Sopenharmony_ci**Example**
2486e41f4b71Sopenharmony_ci
2487e41f4b71Sopenharmony_ci```ts
2488e41f4b71Sopenharmony_citry {
2489e41f4b71Sopenharmony_ci  let getLeftTextOfCursorCallback = (length: number) => {
2490e41f4b71Sopenharmony_ci    console.info(`Succeeded in unsubscribing getLeftTextOfCursor, length: ${length}`);
2491e41f4b71Sopenharmony_ci    let text:string = "";
2492e41f4b71Sopenharmony_ci    return text;
2493e41f4b71Sopenharmony_ci  };
2494e41f4b71Sopenharmony_ci  inputMethodController.off('getLeftTextOfCursor', getLeftTextOfCursorCallback);
2495e41f4b71Sopenharmony_ci  inputMethodController.off('getLeftTextOfCursor');
2496e41f4b71Sopenharmony_ci} catch(err) {
2497e41f4b71Sopenharmony_ci  console.error(`Failed to unsubscribing getLeftTextOfCursor. err: ${JSON.stringify(err)}`);
2498e41f4b71Sopenharmony_ci}
2499e41f4b71Sopenharmony_ci```
2500e41f4b71Sopenharmony_ci
2501e41f4b71Sopenharmony_ci### on('getRightTextOfCursor')<sup>10+</sup>
2502e41f4b71Sopenharmony_ci
2503e41f4b71Sopenharmony_cion(type: 'getRightTextOfCursor', callback: (length: number) => string): void
2504e41f4b71Sopenharmony_ci
2505e41f4b71Sopenharmony_ciEnables listening for the event of obtaining the length of text deleted rightward. This API uses an asynchronous callback to return the result.
2506e41f4b71Sopenharmony_ci
2507e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2508e41f4b71Sopenharmony_ci
2509e41f4b71Sopenharmony_ci**Parameters**
2510e41f4b71Sopenharmony_ci
2511e41f4b71Sopenharmony_ci| Name  | Type  | Mandatory| Description    |
2512e41f4b71Sopenharmony_ci| -------- | ----- | ---- | ------ |
2513e41f4b71Sopenharmony_ci| type     | string  | Yes  | Listening type. The value is fixed at **'getRightTextOfCursor'**.|
2514e41f4b71Sopenharmony_ci| callback | (length: number) => string | Yes  | Callback used to obtain the text of the specified length deleted rightward.|
2515e41f4b71Sopenharmony_ci
2516e41f4b71Sopenharmony_ci**Error codes**
2517e41f4b71Sopenharmony_ci
2518e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
2519e41f4b71Sopenharmony_ci
2520e41f4b71Sopenharmony_ci| ID| Error Message                            |
2521e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
2522e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
2523e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
2524e41f4b71Sopenharmony_ci
2525e41f4b71Sopenharmony_ci**Example**
2526e41f4b71Sopenharmony_ci
2527e41f4b71Sopenharmony_ci```ts
2528e41f4b71Sopenharmony_citry {
2529e41f4b71Sopenharmony_ci  inputMethodController.on('getRightTextOfCursor', (length: number) => {
2530e41f4b71Sopenharmony_ci    console.info(`Succeeded in subscribing getRightTextOfCursor, length: ${length}`);
2531e41f4b71Sopenharmony_ci    let text:string = "";
2532e41f4b71Sopenharmony_ci    return text;
2533e41f4b71Sopenharmony_ci  });
2534e41f4b71Sopenharmony_ci} catch(err) {
2535e41f4b71Sopenharmony_ci  console.error(`Failed to subscribe getRightTextOfCursor. err: ${JSON.stringify(err)}`);
2536e41f4b71Sopenharmony_ci}
2537e41f4b71Sopenharmony_ci```
2538e41f4b71Sopenharmony_ci
2539e41f4b71Sopenharmony_ci### off('getRightTextOfCursor')<sup>10+</sup>
2540e41f4b71Sopenharmony_ci
2541e41f4b71Sopenharmony_cioff(type: 'getRightTextOfCursor', callback?: (length: number) => string): void
2542e41f4b71Sopenharmony_ci
2543e41f4b71Sopenharmony_ciDisables listening for the event of obtaining the length of text deleted rightward. This API uses an asynchronous callback to return the result.
2544e41f4b71Sopenharmony_ci
2545e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2546e41f4b71Sopenharmony_ci
2547e41f4b71Sopenharmony_ci**Parameters**
2548e41f4b71Sopenharmony_ci
2549e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                                                        |
2550e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------------------------------------ |
2551e41f4b71Sopenharmony_ci| type   | string | Yes  | Listening type. The value is fixed at **'getRightTextOfCursor'**.|
2552e41f4b71Sopenharmony_ci| callback | (length: number) => string | No |Callback used for disable listening, which must be the same as that passed by the **on** API.<br>If this parameter is not specified, listening will be disabled for all callbacks corresponding to the specified type.|
2553e41f4b71Sopenharmony_ci
2554e41f4b71Sopenharmony_ci**Example**
2555e41f4b71Sopenharmony_ci
2556e41f4b71Sopenharmony_ci```ts
2557e41f4b71Sopenharmony_citry {
2558e41f4b71Sopenharmony_ci  let getRightTextOfCursorCallback = (length: number) => {
2559e41f4b71Sopenharmony_ci    console.info(`Succeeded in unsubscribing getRightTextOfCursor, length: ${length}`);
2560e41f4b71Sopenharmony_ci    let text:string = "";
2561e41f4b71Sopenharmony_ci    return text;
2562e41f4b71Sopenharmony_ci  };
2563e41f4b71Sopenharmony_ci  inputMethodController.off('getRightTextOfCursor', getRightTextOfCursorCallback);
2564e41f4b71Sopenharmony_ci  inputMethodController.off('getRightTextOfCursor');
2565e41f4b71Sopenharmony_ci} catch(err) {
2566e41f4b71Sopenharmony_ci  console.error(`Failed to unsubscribing getRightTextOfCursor. err: ${JSON.stringify(err)}`);
2567e41f4b71Sopenharmony_ci}
2568e41f4b71Sopenharmony_ci```
2569e41f4b71Sopenharmony_ci
2570e41f4b71Sopenharmony_ci### on('getTextIndexAtCursor')<sup>10+</sup>
2571e41f4b71Sopenharmony_ci
2572e41f4b71Sopenharmony_cion(type: 'getTextIndexAtCursor', callback: () => number): void
2573e41f4b71Sopenharmony_ci
2574e41f4b71Sopenharmony_ciEnables listening for the event of obtaining the index of text at the cursor. This API uses an asynchronous callback to return the result.
2575e41f4b71Sopenharmony_ci
2576e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2577e41f4b71Sopenharmony_ci
2578e41f4b71Sopenharmony_ci**Parameters**
2579e41f4b71Sopenharmony_ci
2580e41f4b71Sopenharmony_ci| Name  | Type  | Mandatory| Description    |
2581e41f4b71Sopenharmony_ci| -------- | ----- | ---- | ------ |
2582e41f4b71Sopenharmony_ci| type     | string  | Yes  | Listening type. The value is fixed at **'getTextIndexAtCursor'**.|
2583e41f4b71Sopenharmony_ci| callback | () => number | Yes  | Callback used to obtain the index of text at the cursor.|
2584e41f4b71Sopenharmony_ci
2585e41f4b71Sopenharmony_ci**Error codes**
2586e41f4b71Sopenharmony_ci
2587e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
2588e41f4b71Sopenharmony_ci
2589e41f4b71Sopenharmony_ci| ID| Error Message                            |
2590e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
2591e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
2592e41f4b71Sopenharmony_ci| 12800009 | input method client is detached. |
2593e41f4b71Sopenharmony_ci
2594e41f4b71Sopenharmony_ci**Example**
2595e41f4b71Sopenharmony_ci
2596e41f4b71Sopenharmony_ci```ts
2597e41f4b71Sopenharmony_citry {
2598e41f4b71Sopenharmony_ci  inputMethodController.on('getTextIndexAtCursor', () => {
2599e41f4b71Sopenharmony_ci    console.info(`Succeeded in subscribing getTextIndexAtCursor.`);
2600e41f4b71Sopenharmony_ci    let index:number = 0;
2601e41f4b71Sopenharmony_ci    return index;
2602e41f4b71Sopenharmony_ci  });
2603e41f4b71Sopenharmony_ci} catch(err) {
2604e41f4b71Sopenharmony_ci  console.error(`Failed to subscribe getTextIndexAtCursor. err: ${JSON.stringify(err)}`);
2605e41f4b71Sopenharmony_ci}
2606e41f4b71Sopenharmony_ci```
2607e41f4b71Sopenharmony_ci
2608e41f4b71Sopenharmony_ci### off('getTextIndexAtCursor')<sup>10+</sup>
2609e41f4b71Sopenharmony_ci
2610e41f4b71Sopenharmony_cioff(type: 'getTextIndexAtCursor', callback?: () => number): void
2611e41f4b71Sopenharmony_ci
2612e41f4b71Sopenharmony_ciDisables listening for the event of obtaining the index of text at the cursor. This API uses an asynchronous callback to return the result.
2613e41f4b71Sopenharmony_ci
2614e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2615e41f4b71Sopenharmony_ci
2616e41f4b71Sopenharmony_ci**Parameters**
2617e41f4b71Sopenharmony_ci
2618e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                                                        |
2619e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------------------------------------ |
2620e41f4b71Sopenharmony_ci| type   | string | Yes  | Listening type. The value is fixed at **'getTextIndexAtCursor'**.|
2621e41f4b71Sopenharmony_ci| callback | () => number | No | Callback used for disable listening, which must be the same as that passed by the **on** API.<br>If this parameter is not specified, listening will be disabled for all callbacks corresponding to the specified type.|
2622e41f4b71Sopenharmony_ci
2623e41f4b71Sopenharmony_ci**Example**
2624e41f4b71Sopenharmony_ci
2625e41f4b71Sopenharmony_ci```ts
2626e41f4b71Sopenharmony_citry {
2627e41f4b71Sopenharmony_ci  let getTextIndexAtCursorCallback = () => {
2628e41f4b71Sopenharmony_ci    console.info(`Succeeded in unsubscribing getTextIndexAtCursor.`);
2629e41f4b71Sopenharmony_ci    let index:number = 0;
2630e41f4b71Sopenharmony_ci    return index;
2631e41f4b71Sopenharmony_ci  };
2632e41f4b71Sopenharmony_ci  inputMethodController.off('getTextIndexAtCursor', getTextIndexAtCursorCallback);
2633e41f4b71Sopenharmony_ci  inputMethodController.off('getTextIndexAtCursor');
2634e41f4b71Sopenharmony_ci} catch(err) {
2635e41f4b71Sopenharmony_ci  console.error(`Failed to unsubscribing getTextIndexAtCursor. err: ${JSON.stringify(err)}`);
2636e41f4b71Sopenharmony_ci}
2637e41f4b71Sopenharmony_ci```
2638e41f4b71Sopenharmony_ci
2639e41f4b71Sopenharmony_ci## InputMethodSetting<sup>8+</sup>
2640e41f4b71Sopenharmony_ci
2641e41f4b71Sopenharmony_ciIn the following API examples, you must first use [getSetting](#inputmethodgetsetting9) to obtain an **InputMethodSetting** instance, and then call the APIs using the obtained instance.
2642e41f4b71Sopenharmony_ci
2643e41f4b71Sopenharmony_ci### on('imeChange')<sup>9+</sup>
2644e41f4b71Sopenharmony_ci
2645e41f4b71Sopenharmony_cion(type: 'imeChange', callback: (inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype) => void): void
2646e41f4b71Sopenharmony_ci
2647e41f4b71Sopenharmony_ciEnables listening for the input method and subtype change event. This API uses an asynchronous callback to return the result.
2648e41f4b71Sopenharmony_ci
2649e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2650e41f4b71Sopenharmony_ci
2651e41f4b71Sopenharmony_ci**Parameters**
2652e41f4b71Sopenharmony_ci
2653e41f4b71Sopenharmony_ci| Name  | Type                           | Mandatory| Description                                                        |
2654e41f4b71Sopenharmony_ci| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
2655e41f4b71Sopenharmony_ci| type     | string                        | Yes  | Listening type. The value is fixed at **'imeChange'**.|
2656e41f4b71Sopenharmony_ci| callback | (inputMethodProperty: [InputMethodProperty](#inputmethodproperty8), inputMethodSubtype: [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)) => void  | Yes| Callback used to return the input method attributes and subtype.|
2657e41f4b71Sopenharmony_ci
2658e41f4b71Sopenharmony_ci**Example**
2659e41f4b71Sopenharmony_ci
2660e41f4b71Sopenharmony_ci```ts
2661e41f4b71Sopenharmony_ciimport { InputMethodSubtype } from '@kit.IMEKit';
2662e41f4b71Sopenharmony_citry {
2663e41f4b71Sopenharmony_ci  inputMethodSetting.on('imeChange', (inputMethodProperty: inputMethod.InputMethodProperty, inputMethodSubtype: InputMethodSubtype) => {
2664e41f4b71Sopenharmony_ci    console.log('Succeeded in subscribing imeChange: inputMethodProperty: ' + JSON.stringify(inputMethodProperty) + " , inputMethodSubtype: " + JSON.stringify(inputMethodSubtype));
2665e41f4b71Sopenharmony_ci  });
2666e41f4b71Sopenharmony_ci} catch(err) {
2667e41f4b71Sopenharmony_ci  console.error(`Failed to unsubscribing inputMethodProperty. err: ${JSON.stringify(err)}`);
2668e41f4b71Sopenharmony_ci}
2669e41f4b71Sopenharmony_ci```
2670e41f4b71Sopenharmony_ci
2671e41f4b71Sopenharmony_ci### off('imeChange')<sup>9+</sup>
2672e41f4b71Sopenharmony_ci
2673e41f4b71Sopenharmony_cioff(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype) => void): void
2674e41f4b71Sopenharmony_ci
2675e41f4b71Sopenharmony_ciDisables listening for the input method and subtype change event. This API uses an asynchronous callback to return the result.
2676e41f4b71Sopenharmony_ci
2677e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2678e41f4b71Sopenharmony_ci
2679e41f4b71Sopenharmony_ci**Parameters**
2680e41f4b71Sopenharmony_ci
2681e41f4b71Sopenharmony_ci| Name  | Type   | Mandatory| Description         |
2682e41f4b71Sopenharmony_ci| -------- | --------- | ---- | --------------- |
2683e41f4b71Sopenharmony_ci| type     | string    | Yes  | Listening type. The value is fixed at **'imeChange'**.|
2684e41f4b71Sopenharmony_ci| callback | (inputMethodProperty: [InputMethodProperty](#inputmethodproperty8), inputMethodSubtype: [InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)) => void  | No| Callback used to return the input method attributes and subtype.|
2685e41f4b71Sopenharmony_ci
2686e41f4b71Sopenharmony_ci**Example**
2687e41f4b71Sopenharmony_ci
2688e41f4b71Sopenharmony_ci```ts
2689e41f4b71Sopenharmony_ciinputMethodSetting.off('imeChange');
2690e41f4b71Sopenharmony_ci```
2691e41f4b71Sopenharmony_ci
2692e41f4b71Sopenharmony_ci### listInputMethodSubtype<sup>9+</sup>
2693e41f4b71Sopenharmony_ci
2694e41f4b71Sopenharmony_cilistInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: AsyncCallback&lt;Array&lt;InputMethodSubtype&gt;&gt;): void
2695e41f4b71Sopenharmony_ci
2696e41f4b71Sopenharmony_ciObtains all subtypes of a specified input method. This API uses an asynchronous callback to return the result.
2697e41f4b71Sopenharmony_ci
2698e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2699e41f4b71Sopenharmony_ci
2700e41f4b71Sopenharmony_ci**Parameters**
2701e41f4b71Sopenharmony_ci
2702e41f4b71Sopenharmony_ci| Name  | Type                                              | Mandatory| Description                  |
2703e41f4b71Sopenharmony_ci| -------- | -------------------------------------------------- | ---- | ---------------------- |
2704e41f4b71Sopenharmony_ci| inputMethodProperty | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method.|
2705e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>&gt; | Yes| Callback used to return all subtypes of the specified input method.|
2706e41f4b71Sopenharmony_ci
2707e41f4b71Sopenharmony_ci**Error codes**
2708e41f4b71Sopenharmony_ci
2709e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
2710e41f4b71Sopenharmony_ci
2711e41f4b71Sopenharmony_ci| ID| Error Message                            |
2712e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
2713e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
2714e41f4b71Sopenharmony_ci| 12800001 | package manager error.                 |
2715e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
2716e41f4b71Sopenharmony_ci
2717e41f4b71Sopenharmony_ci**Example**
2718e41f4b71Sopenharmony_ci
2719e41f4b71Sopenharmony_ci```ts
2720e41f4b71Sopenharmony_ciimport { InputMethodSubtype } from '@kit.IMEKit';
2721e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2722e41f4b71Sopenharmony_ci
2723e41f4b71Sopenharmony_cilet inputMethodProperty: inputMethod.InputMethodProperty = {
2724e41f4b71Sopenharmony_ci  name: 'com.example.kikakeyboard',
2725e41f4b71Sopenharmony_ci  id: 'propertyId',
2726e41f4b71Sopenharmony_ci}
2727e41f4b71Sopenharmony_cilet inputMethodSetting = inputMethod.getSetting();
2728e41f4b71Sopenharmony_citry {
2729e41f4b71Sopenharmony_ci  inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err: BusinessError, data: Array<InputMethodSubtype>) => {
2730e41f4b71Sopenharmony_ci    if (err) {
2731e41f4b71Sopenharmony_ci      console.error(`Failed to listInputMethodSubtype: ${JSON.stringify(err)}`);
2732e41f4b71Sopenharmony_ci      return;
2733e41f4b71Sopenharmony_ci    }
2734e41f4b71Sopenharmony_ci    console.log('Succeeded in listing inputMethodSubtype.');
2735e41f4b71Sopenharmony_ci  });
2736e41f4b71Sopenharmony_ci} catch (err) {
2737e41f4b71Sopenharmony_ci  console.error(`Failed to listInputMethodSubtype: ${JSON.stringify(err)}`);
2738e41f4b71Sopenharmony_ci}
2739e41f4b71Sopenharmony_ci```
2740e41f4b71Sopenharmony_ci
2741e41f4b71Sopenharmony_ci### listInputMethodSubtype<sup>9+</sup>
2742e41f4b71Sopenharmony_ci
2743e41f4b71Sopenharmony_cilistInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise&lt;Array&lt;InputMethodSubtype&gt;&gt;
2744e41f4b71Sopenharmony_ci
2745e41f4b71Sopenharmony_ciObtains all subtypes of a specified input method. This API uses a promise to return the result.
2746e41f4b71Sopenharmony_ci
2747e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2748e41f4b71Sopenharmony_ci
2749e41f4b71Sopenharmony_ci**Parameters**
2750e41f4b71Sopenharmony_ci
2751e41f4b71Sopenharmony_ci| Name  | Type                                              | Mandatory| Description                  |
2752e41f4b71Sopenharmony_ci| -------- | -------------------------------------------------- | ---- | ---------------------- |
2753e41f4b71Sopenharmony_ci| inputMethodProperty | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method.|
2754e41f4b71Sopenharmony_ci
2755e41f4b71Sopenharmony_ci**Return value**
2756e41f4b71Sopenharmony_ci
2757e41f4b71Sopenharmony_ci| Type                                                       | Description                  |
2758e41f4b71Sopenharmony_ci| ----------------------------------------------------------- | ---------------------- |
2759e41f4b71Sopenharmony_ci| Promise<Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>> | Promise used to return all subtypes of the specified input method.|
2760e41f4b71Sopenharmony_ci
2761e41f4b71Sopenharmony_ci**Error codes**
2762e41f4b71Sopenharmony_ci
2763e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
2764e41f4b71Sopenharmony_ci
2765e41f4b71Sopenharmony_ci| ID| Error Message                            |
2766e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
2767e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.           |
2768e41f4b71Sopenharmony_ci| 12800001 | package manager error.                 |
2769e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
2770e41f4b71Sopenharmony_ci
2771e41f4b71Sopenharmony_ci**Example**
2772e41f4b71Sopenharmony_ci
2773e41f4b71Sopenharmony_ci```ts
2774e41f4b71Sopenharmony_ciimport { InputMethodSubtype } from '@kit.IMEKit';
2775e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2776e41f4b71Sopenharmony_ci
2777e41f4b71Sopenharmony_cilet inputMethodProperty: inputMethod.InputMethodProperty = {
2778e41f4b71Sopenharmony_ci  name: 'com.example.kikakeyboard',
2779e41f4b71Sopenharmony_ci  id: 'propertyId',
2780e41f4b71Sopenharmony_ci}
2781e41f4b71Sopenharmony_cilet inputMethodSetting = inputMethod.getSetting();
2782e41f4b71Sopenharmony_citry {
2783e41f4b71Sopenharmony_ci  inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data: Array<InputMethodSubtype>) => {
2784e41f4b71Sopenharmony_ci    console.log('Succeeded in listing inputMethodSubtype.');
2785e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
2786e41f4b71Sopenharmony_ci    console.error(`Failed to listInputMethodSubtype: ${JSON.stringify(err)}`);
2787e41f4b71Sopenharmony_ci  })
2788e41f4b71Sopenharmony_ci} catch(err) {
2789e41f4b71Sopenharmony_ci  console.error(`Failed to listInputMethodSubtype: ${JSON.stringify(err)}`);
2790e41f4b71Sopenharmony_ci}
2791e41f4b71Sopenharmony_ci```
2792e41f4b71Sopenharmony_ci
2793e41f4b71Sopenharmony_ci### listCurrentInputMethodSubtype<sup>9+</sup>
2794e41f4b71Sopenharmony_ci
2795e41f4b71Sopenharmony_cilistCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSubtype&gt;&gt;): void
2796e41f4b71Sopenharmony_ci
2797e41f4b71Sopenharmony_ciObtains all subtypes of this input method. This API uses an asynchronous callback to return the result.
2798e41f4b71Sopenharmony_ci
2799e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2800e41f4b71Sopenharmony_ci
2801e41f4b71Sopenharmony_ci**Parameters**
2802e41f4b71Sopenharmony_ci
2803e41f4b71Sopenharmony_ci| Name  | Type                                              | Mandatory| Description                  |
2804e41f4b71Sopenharmony_ci| -------- | -------------------------------------------------- | ---- | ---------------------- |
2805e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>&gt; | Yes  | Callback used to return all subtypes of the current input method.|
2806e41f4b71Sopenharmony_ci
2807e41f4b71Sopenharmony_ci**Error codes**
2808e41f4b71Sopenharmony_ci
2809e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
2810e41f4b71Sopenharmony_ci
2811e41f4b71Sopenharmony_ci| ID| Error Message                            |
2812e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
2813e41f4b71Sopenharmony_ci| 12800001 | package manager error.                 |
2814e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
2815e41f4b71Sopenharmony_ci
2816e41f4b71Sopenharmony_ci**Example**
2817e41f4b71Sopenharmony_ci
2818e41f4b71Sopenharmony_ci```ts
2819e41f4b71Sopenharmony_ciimport { InputMethodSubtype } from '@kit.IMEKit';
2820e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2821e41f4b71Sopenharmony_ci
2822e41f4b71Sopenharmony_cilet inputMethodSetting = inputMethod.getSetting();
2823e41f4b71Sopenharmony_citry {
2824e41f4b71Sopenharmony_ci  inputMethodSetting.listCurrentInputMethodSubtype((err: BusinessError, data: Array<InputMethodSubtype>) => {
2825e41f4b71Sopenharmony_ci    if (err) {
2826e41f4b71Sopenharmony_ci      console.error(`Failed to listCurrentInputMethodSubtype: ${JSON.stringify(err)}`);
2827e41f4b71Sopenharmony_ci      return;
2828e41f4b71Sopenharmony_ci    }
2829e41f4b71Sopenharmony_ci    console.log('Succeeded in listing currentInputMethodSubtype.');
2830e41f4b71Sopenharmony_ci  });
2831e41f4b71Sopenharmony_ci} catch(err) {
2832e41f4b71Sopenharmony_ci  console.error(`Failed to listCurrentInputMethodSubtype: ${JSON.stringify(err)}`);
2833e41f4b71Sopenharmony_ci}
2834e41f4b71Sopenharmony_ci```
2835e41f4b71Sopenharmony_ci
2836e41f4b71Sopenharmony_ci### listCurrentInputMethodSubtype<sup>9+</sup>
2837e41f4b71Sopenharmony_ci
2838e41f4b71Sopenharmony_cilistCurrentInputMethodSubtype(): Promise&lt;Array&lt;InputMethodSubtype&gt;&gt;
2839e41f4b71Sopenharmony_ci
2840e41f4b71Sopenharmony_ciObtains all subtypes of this input method. This API uses a promise to return the result.
2841e41f4b71Sopenharmony_ci
2842e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2843e41f4b71Sopenharmony_ci
2844e41f4b71Sopenharmony_ci**Return value**
2845e41f4b71Sopenharmony_ci
2846e41f4b71Sopenharmony_ci| Type                                                       | Description                  |
2847e41f4b71Sopenharmony_ci| ----------------------------------------------------------- | ---------------------- |
2848e41f4b71Sopenharmony_ci| Promise<Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>> | Promise used to return all subtypes of the current input method.|
2849e41f4b71Sopenharmony_ci
2850e41f4b71Sopenharmony_ci**Error codes**
2851e41f4b71Sopenharmony_ci
2852e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
2853e41f4b71Sopenharmony_ci
2854e41f4b71Sopenharmony_ci| ID| Error Message                            |
2855e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
2856e41f4b71Sopenharmony_ci| 12800001 | package manager error.                 |
2857e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
2858e41f4b71Sopenharmony_ci
2859e41f4b71Sopenharmony_ci**Example**
2860e41f4b71Sopenharmony_ci
2861e41f4b71Sopenharmony_ci```ts
2862e41f4b71Sopenharmony_ciimport { InputMethodSubtype } from '@kit.IMEKit';
2863e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2864e41f4b71Sopenharmony_ci
2865e41f4b71Sopenharmony_cilet inputMethodSetting = inputMethod.getSetting();
2866e41f4b71Sopenharmony_citry {
2867e41f4b71Sopenharmony_ci  inputMethodSetting.listCurrentInputMethodSubtype().then((data: Array<InputMethodSubtype>) => {
2868e41f4b71Sopenharmony_ci    console.log('Succeeded in listing currentInputMethodSubtype.');
2869e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
2870e41f4b71Sopenharmony_ci    console.error(`Failed to listCurrentInputMethodSubtype: ${JSON.stringify(err)}`);
2871e41f4b71Sopenharmony_ci  })
2872e41f4b71Sopenharmony_ci} catch(err) {
2873e41f4b71Sopenharmony_ci  console.error(`Failed to listCurrentInputMethodSubtype: ${JSON.stringify(err)}`);
2874e41f4b71Sopenharmony_ci}
2875e41f4b71Sopenharmony_ci```
2876e41f4b71Sopenharmony_ci
2877e41f4b71Sopenharmony_ci### getInputMethods<sup>9+</sup>
2878e41f4b71Sopenharmony_ci
2879e41f4b71Sopenharmony_cigetInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;): void
2880e41f4b71Sopenharmony_ci
2881e41f4b71Sopenharmony_ciObtains a list of activated or deactivated input methods. This API uses an asynchronous callback to return the result.
2882e41f4b71Sopenharmony_ci
2883e41f4b71Sopenharmony_ci> **NOTE**
2884e41f4b71Sopenharmony_ci> 
2885e41f4b71Sopenharmony_ci> An activated input method refers to an input method that is enabled. The default input method is enabled by default. Other input methods can be enabled or disabled as needed.
2886e41f4b71Sopenharmony_ci> 
2887e41f4b71Sopenharmony_ci> The list of activated input methods includes the default input method and enabled input methods. The list of deactivated input methods includes all installed input methods except the enabled ones.
2888e41f4b71Sopenharmony_ci
2889e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2890e41f4b71Sopenharmony_ci
2891e41f4b71Sopenharmony_ci**Parameters**
2892e41f4b71Sopenharmony_ci
2893e41f4b71Sopenharmony_ci| Name  | Type                                               | Mandatory| Description                         |
2894e41f4b71Sopenharmony_ci| -------- | --------------------------------------------------- | ---- | ----------------------------- |
2895e41f4b71Sopenharmony_ci| enable   | boolean                                             | Yes  |Whether to return a list of activated input methods. The value **true** means to return a list of activated input methods, and **false** means to return a list of deactivated input methods.|
2896e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;Array<[InputMethodProperty](#inputmethodproperty8)>&gt; |  Yes | Callback used to return a list of activated or deactivated input methods.|
2897e41f4b71Sopenharmony_ci
2898e41f4b71Sopenharmony_ci**Error codes**
2899e41f4b71Sopenharmony_ci
2900e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
2901e41f4b71Sopenharmony_ci
2902e41f4b71Sopenharmony_ci| ID| Error Message                           |
2903e41f4b71Sopenharmony_ci| -------- | ----------------------------------- |
2904e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2905e41f4b71Sopenharmony_ci| 12800001 | package manager error.               |
2906e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
2907e41f4b71Sopenharmony_ci
2908e41f4b71Sopenharmony_ci**Example**
2909e41f4b71Sopenharmony_ci
2910e41f4b71Sopenharmony_ci```ts
2911e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2912e41f4b71Sopenharmony_ci
2913e41f4b71Sopenharmony_citry {
2914e41f4b71Sopenharmony_ci  inputMethodSetting.getInputMethods(true, (err: BusinessError, data: Array<inputMethod.InputMethodProperty>) => {
2915e41f4b71Sopenharmony_ci    if (err) {
2916e41f4b71Sopenharmony_ci      console.error(`Failed to getInputMethods: ${JSON.stringify(err)}`);
2917e41f4b71Sopenharmony_ci      return;
2918e41f4b71Sopenharmony_ci    }
2919e41f4b71Sopenharmony_ci    console.log('Succeeded in getting inputMethods.');
2920e41f4b71Sopenharmony_ci  });
2921e41f4b71Sopenharmony_ci} catch (err) {
2922e41f4b71Sopenharmony_ci  console.error(`Failed to getInputMethods: ${JSON.stringify(err)}`);
2923e41f4b71Sopenharmony_ci}
2924e41f4b71Sopenharmony_ci```
2925e41f4b71Sopenharmony_ci
2926e41f4b71Sopenharmony_ci### getInputMethods<sup>9+</sup>
2927e41f4b71Sopenharmony_ci
2928e41f4b71Sopenharmony_cigetInputMethods(enable: boolean): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
2929e41f4b71Sopenharmony_ci
2930e41f4b71Sopenharmony_ciObtains a list of activated or deactivated input methods. This API uses a promise to return the result.
2931e41f4b71Sopenharmony_ci
2932e41f4b71Sopenharmony_ci> **NOTE**
2933e41f4b71Sopenharmony_ci> 
2934e41f4b71Sopenharmony_ci> An activated input method refers to an input method that is enabled. The default input method is enabled by default. Other input methods can be enabled or disabled as needed.
2935e41f4b71Sopenharmony_ci> 
2936e41f4b71Sopenharmony_ci> The list of activated input methods includes the default input method and enabled input methods. The list of deactivated input methods includes all installed input methods except the enabled ones.
2937e41f4b71Sopenharmony_ci
2938e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2939e41f4b71Sopenharmony_ci
2940e41f4b71Sopenharmony_ci**Parameters**
2941e41f4b71Sopenharmony_ci
2942e41f4b71Sopenharmony_ci| Name| Type   | Mandatory| Description                   |
2943e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ----------------------- |
2944e41f4b71Sopenharmony_ci| enable | boolean | Yes  |Whether to return a list of activated input methods. The value **true** means to return a list of activated input methods, and **false** means to return a list of deactivated input methods.|
2945e41f4b71Sopenharmony_ci
2946e41f4b71Sopenharmony_ci**Return value**
2947e41f4b71Sopenharmony_ci
2948e41f4b71Sopenharmony_ci| Type                                                        | Description                                      |
2949e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | ------------------------------------------ |
2950e41f4b71Sopenharmony_ci| Promise\<Array\<[InputMethodProperty](#inputmethodproperty8)>> | Promise used to return a list of activated or deactivated input methods.|
2951e41f4b71Sopenharmony_ci
2952e41f4b71Sopenharmony_ci**Error codes**
2953e41f4b71Sopenharmony_ci
2954e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
2955e41f4b71Sopenharmony_ci
2956e41f4b71Sopenharmony_ci| ID| Error Message                           |
2957e41f4b71Sopenharmony_ci| -------- | ----------------------------------- |
2958e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2959e41f4b71Sopenharmony_ci| 12800001 | package manager error.               |
2960e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
2961e41f4b71Sopenharmony_ci
2962e41f4b71Sopenharmony_ci**Example**
2963e41f4b71Sopenharmony_ci
2964e41f4b71Sopenharmony_ci```ts
2965e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2966e41f4b71Sopenharmony_ci
2967e41f4b71Sopenharmony_citry {
2968e41f4b71Sopenharmony_ci  inputMethodSetting.getInputMethods(true).then((data: Array<inputMethod.InputMethodProperty>) => {
2969e41f4b71Sopenharmony_ci    console.log('Succeeded in getting inputMethods.');
2970e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
2971e41f4b71Sopenharmony_ci    console.error(`Failed to getInputMethods: ${JSON.stringify(err)}`);
2972e41f4b71Sopenharmony_ci  })
2973e41f4b71Sopenharmony_ci} catch(err) {
2974e41f4b71Sopenharmony_ci  console.error(`Failed to getInputMethods: ${JSON.stringify(err)}`);
2975e41f4b71Sopenharmony_ci}
2976e41f4b71Sopenharmony_ci```
2977e41f4b71Sopenharmony_ci
2978e41f4b71Sopenharmony_ci### getInputMethodsSync<sup>11+</sup>
2979e41f4b71Sopenharmony_ci
2980e41f4b71Sopenharmony_cigetInputMethodsSync(enable: boolean): Array&lt;InputMethodProperty&gt;
2981e41f4b71Sopenharmony_ci
2982e41f4b71Sopenharmony_ciObtains a list of activated or deactivated input methods. This API returns the result synchronously.
2983e41f4b71Sopenharmony_ci
2984e41f4b71Sopenharmony_ci> **NOTE**
2985e41f4b71Sopenharmony_ci>
2986e41f4b71Sopenharmony_ci> An activated input method refers to an input method that is enabled. The default input method is enabled by default. Other input methods can be enabled or disabled as needed.
2987e41f4b71Sopenharmony_ci>
2988e41f4b71Sopenharmony_ci> The list of activated input methods includes the default input method and enabled input methods. The list of deactivated input methods includes all installed input methods except the enabled ones.
2989e41f4b71Sopenharmony_ci
2990e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
2991e41f4b71Sopenharmony_ci
2992e41f4b71Sopenharmony_ci**Parameters**
2993e41f4b71Sopenharmony_ci
2994e41f4b71Sopenharmony_ci| Name| Type   | Mandatory| Description                   |
2995e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ----------------------- |
2996e41f4b71Sopenharmony_ci| enable | boolean | Yes  |Whether to return a list of activated input methods. The value **true** means to return a list of activated input methods, and **false** means to return a list of deactivated input methods.|
2997e41f4b71Sopenharmony_ci
2998e41f4b71Sopenharmony_ci**Return value**
2999e41f4b71Sopenharmony_ci
3000e41f4b71Sopenharmony_ci| Type                                                | Description                         |
3001e41f4b71Sopenharmony_ci| ---------------------------------------------------- | ----------------------------- |
3002e41f4b71Sopenharmony_ci| Array\<[InputMethodProperty](#inputmethodproperty8)> | List of activated or deactivated input methods.|
3003e41f4b71Sopenharmony_ci
3004e41f4b71Sopenharmony_ci**Error codes**
3005e41f4b71Sopenharmony_ci
3006e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
3007e41f4b71Sopenharmony_ci
3008e41f4b71Sopenharmony_ci| ID| Error Message                            |
3009e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
3010e41f4b71Sopenharmony_ci| 401      | parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3011e41f4b71Sopenharmony_ci| 12800001 | bundle manager error.                 |
3012e41f4b71Sopenharmony_ci| 12800008 |input method manager service error. |
3013e41f4b71Sopenharmony_ci
3014e41f4b71Sopenharmony_ci**Example**
3015e41f4b71Sopenharmony_ci
3016e41f4b71Sopenharmony_ci```ts
3017e41f4b71Sopenharmony_citry {
3018e41f4b71Sopenharmony_ci  let imeProp = inputMethodSetting.getInputMethodsSync(true);
3019e41f4b71Sopenharmony_ci} catch(err) {
3020e41f4b71Sopenharmony_ci  console.error(`Failed to getInputMethods: ${JSON.stringify(err)}`);
3021e41f4b71Sopenharmony_ci}
3022e41f4b71Sopenharmony_ci```
3023e41f4b71Sopenharmony_ci
3024e41f4b71Sopenharmony_ci### getAllInputMethods<sup>11+</sup>
3025e41f4b71Sopenharmony_ci
3026e41f4b71Sopenharmony_cigetAllInputMethods(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;): void
3027e41f4b71Sopenharmony_ci
3028e41f4b71Sopenharmony_ciObtains a list of all input methods. This API uses an asynchronous callback to return the result.
3029e41f4b71Sopenharmony_ci
3030e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
3031e41f4b71Sopenharmony_ci
3032e41f4b71Sopenharmony_ci**Parameters**
3033e41f4b71Sopenharmony_ci
3034e41f4b71Sopenharmony_ci| Name  | Type                                                        | Mandatory| Description                          |
3035e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
3036e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;Array<[InputMethodProperty](#inputmethodproperty8)>&gt; | Yes  | Callback used to return a list of all input methods.|
3037e41f4b71Sopenharmony_ci
3038e41f4b71Sopenharmony_ci**Error codes**
3039e41f4b71Sopenharmony_ci
3040e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
3041e41f4b71Sopenharmony_ci
3042e41f4b71Sopenharmony_ci| ID| Error Message                           |
3043e41f4b71Sopenharmony_ci| -------- | ----------------------------------- |
3044e41f4b71Sopenharmony_ci| 12800001 | bundle manager error.               |
3045e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
3046e41f4b71Sopenharmony_ci
3047e41f4b71Sopenharmony_ci**Example**
3048e41f4b71Sopenharmony_ci
3049e41f4b71Sopenharmony_ci```ts
3050e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3051e41f4b71Sopenharmony_ci
3052e41f4b71Sopenharmony_citry {
3053e41f4b71Sopenharmony_ci  inputMethodSetting.getAllInputMethods((err: BusinessError, data: Array<inputMethod.InputMethodProperty>) => {
3054e41f4b71Sopenharmony_ci    if (err) {
3055e41f4b71Sopenharmony_ci      console.error(`Failed to getAllInputMethods: ${JSON.stringify(err)}`);
3056e41f4b71Sopenharmony_ci      return;
3057e41f4b71Sopenharmony_ci    }
3058e41f4b71Sopenharmony_ci    console.log('Succeeded in getting all inputMethods.');
3059e41f4b71Sopenharmony_ci  });
3060e41f4b71Sopenharmony_ci} catch (err) {
3061e41f4b71Sopenharmony_ci  console.error(`Failed to getAllInputMethods: ${JSON.stringify(err)}`);
3062e41f4b71Sopenharmony_ci}
3063e41f4b71Sopenharmony_ci```
3064e41f4b71Sopenharmony_ci
3065e41f4b71Sopenharmony_ci### getAllInputMethods<sup>11+</sup>
3066e41f4b71Sopenharmony_ci
3067e41f4b71Sopenharmony_cigetAllInputMethods(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
3068e41f4b71Sopenharmony_ci
3069e41f4b71Sopenharmony_ciObtains a list of all input methods. This API uses a promise to return the result.
3070e41f4b71Sopenharmony_ci
3071e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
3072e41f4b71Sopenharmony_ci
3073e41f4b71Sopenharmony_ci**Return value**
3074e41f4b71Sopenharmony_ci
3075e41f4b71Sopenharmony_ci| Type                                                        | Description                             |
3076e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | --------------------------------- |
3077e41f4b71Sopenharmony_ci| Promise\<Array\<[InputMethodProperty](#inputmethodproperty8)>> | Promise used to return a list of all input methods.|
3078e41f4b71Sopenharmony_ci
3079e41f4b71Sopenharmony_ci**Error codes**
3080e41f4b71Sopenharmony_ci
3081e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) and [Universal Error Codes](../errorcode-universal.md).
3082e41f4b71Sopenharmony_ci
3083e41f4b71Sopenharmony_ci| ID| Error Message                           |
3084e41f4b71Sopenharmony_ci| -------- | ----------------------------------- |
3085e41f4b71Sopenharmony_ci| 12800001 | bundle manager error.              |
3086e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
3087e41f4b71Sopenharmony_ci
3088e41f4b71Sopenharmony_ci**Example**
3089e41f4b71Sopenharmony_ci
3090e41f4b71Sopenharmony_ci```ts
3091e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3092e41f4b71Sopenharmony_ci
3093e41f4b71Sopenharmony_ciinputMethodSetting.getAllInputMethods().then((data: Array<inputMethod.InputMethodProperty>) => {
3094e41f4b71Sopenharmony_ci  console.log('Succeeded in getting all inputMethods.');
3095e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
3096e41f4b71Sopenharmony_ci  console.error(`Failed to getAllInputMethods: ${JSON.stringify(err)}`);
3097e41f4b71Sopenharmony_ci})
3098e41f4b71Sopenharmony_ci```
3099e41f4b71Sopenharmony_ci
3100e41f4b71Sopenharmony_ci### getAllInputMethodsSync<sup>11+</sup>
3101e41f4b71Sopenharmony_ci
3102e41f4b71Sopenharmony_cigetAllInputMethodsSync(): Array&lt;InputMethodProperty&gt;
3103e41f4b71Sopenharmony_ci
3104e41f4b71Sopenharmony_ciObtains a list of all input methods. This API returns the result synchronously.
3105e41f4b71Sopenharmony_ci
3106e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
3107e41f4b71Sopenharmony_ci
3108e41f4b71Sopenharmony_ci**Return value**
3109e41f4b71Sopenharmony_ci
3110e41f4b71Sopenharmony_ci| Type                                                | Description              |
3111e41f4b71Sopenharmony_ci| ---------------------------------------------------- | ------------------ |
3112e41f4b71Sopenharmony_ci| Array\<[InputMethodProperty](#inputmethodproperty8)> | List of all input methods.|
3113e41f4b71Sopenharmony_ci
3114e41f4b71Sopenharmony_ci**Error codes**
3115e41f4b71Sopenharmony_ci
3116e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md).
3117e41f4b71Sopenharmony_ci
3118e41f4b71Sopenharmony_ci| ID| Error Message                           |
3119e41f4b71Sopenharmony_ci| -------- | ----------------------------------- |
3120e41f4b71Sopenharmony_ci| 12800001 | bundle manager error.              |
3121e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
3122e41f4b71Sopenharmony_ci
3123e41f4b71Sopenharmony_ci**Example**
3124e41f4b71Sopenharmony_ci
3125e41f4b71Sopenharmony_ci```ts
3126e41f4b71Sopenharmony_citry {
3127e41f4b71Sopenharmony_ci  let imeProp = inputMethodSetting.getAllInputMethodsSync();
3128e41f4b71Sopenharmony_ci} catch(err) {
3129e41f4b71Sopenharmony_ci  console.error(`Failed to getAllInputMethodsSync: ${JSON.stringify(err)}`);
3130e41f4b71Sopenharmony_ci}
3131e41f4b71Sopenharmony_ci```
3132e41f4b71Sopenharmony_ci
3133e41f4b71Sopenharmony_ci### showOptionalInputMethods<sup>9+</sup>
3134e41f4b71Sopenharmony_ci
3135e41f4b71Sopenharmony_cishowOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void
3136e41f4b71Sopenharmony_ci
3137e41f4b71Sopenharmony_ciDisplays a dialog box for selecting an input method. This API uses an asynchronous callback to return the result.
3138e41f4b71Sopenharmony_ci
3139e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
3140e41f4b71Sopenharmony_ci
3141e41f4b71Sopenharmony_ci**Parameters**
3142e41f4b71Sopenharmony_ci
3143e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
3144e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
3145e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
3146e41f4b71Sopenharmony_ci
3147e41f4b71Sopenharmony_ci**Error codes**
3148e41f4b71Sopenharmony_ci
3149e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md).
3150e41f4b71Sopenharmony_ci
3151e41f4b71Sopenharmony_ci| ID| Error Message                            |
3152e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
3153e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
3154e41f4b71Sopenharmony_ci
3155e41f4b71Sopenharmony_ci**Example**
3156e41f4b71Sopenharmony_ci
3157e41f4b71Sopenharmony_ci```ts
3158e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3159e41f4b71Sopenharmony_ci
3160e41f4b71Sopenharmony_citry {
3161e41f4b71Sopenharmony_ci  inputMethodSetting.showOptionalInputMethods((err: BusinessError, data: boolean) => {
3162e41f4b71Sopenharmony_ci    if (err) {
3163e41f4b71Sopenharmony_ci      console.error(`Failed to showOptionalInputMethods: ${JSON.stringify(err)}`);
3164e41f4b71Sopenharmony_ci      return;
3165e41f4b71Sopenharmony_ci    }
3166e41f4b71Sopenharmony_ci    console.log('Succeeded in showing optionalInputMethods.');
3167e41f4b71Sopenharmony_ci  });
3168e41f4b71Sopenharmony_ci} catch (err) {
3169e41f4b71Sopenharmony_ci  console.error(`Failed to showOptionalInputMethods: ${JSON.stringify(err)}`);
3170e41f4b71Sopenharmony_ci}
3171e41f4b71Sopenharmony_ci```
3172e41f4b71Sopenharmony_ci
3173e41f4b71Sopenharmony_ci### showOptionalInputMethods<sup>9+</sup>
3174e41f4b71Sopenharmony_ci
3175e41f4b71Sopenharmony_cishowOptionalInputMethods(): Promise&lt;boolean&gt;
3176e41f4b71Sopenharmony_ci
3177e41f4b71Sopenharmony_ciDisplays a dialog box for selecting an input method. This API uses a promise to return the result.
3178e41f4b71Sopenharmony_ci
3179e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
3180e41f4b71Sopenharmony_ci
3181e41f4b71Sopenharmony_ci**Return value**
3182e41f4b71Sopenharmony_ci
3183e41f4b71Sopenharmony_ci| Type| Description|
3184e41f4b71Sopenharmony_ci| -------- | -------- |
3185e41f4b71Sopenharmony_ci| Promise&lt;boolean&gt; | Promise used to return the result. If the operation is successful, **err** is **undefined** and **data** is **true**. Otherwise, **err** is an error object.|
3186e41f4b71Sopenharmony_ci
3187e41f4b71Sopenharmony_ci**Error codes**
3188e41f4b71Sopenharmony_ci
3189e41f4b71Sopenharmony_ciFor details about the error codes, see [Input Method Framework Error Codes](errorcode-inputmethod-framework.md).
3190e41f4b71Sopenharmony_ci
3191e41f4b71Sopenharmony_ci| ID| Error Message                            |
3192e41f4b71Sopenharmony_ci| -------- | -------------------------------------- |
3193e41f4b71Sopenharmony_ci| 12800008 | input method manager service error. |
3194e41f4b71Sopenharmony_ci
3195e41f4b71Sopenharmony_ci**Example**
3196e41f4b71Sopenharmony_ci
3197e41f4b71Sopenharmony_ci```ts
3198e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3199e41f4b71Sopenharmony_ci
3200e41f4b71Sopenharmony_ciinputMethodSetting.showOptionalInputMethods().then((data: boolean) => {
3201e41f4b71Sopenharmony_ci  console.log('Succeeded in showing optionalInputMethods.');
3202e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
3203e41f4b71Sopenharmony_ci  console.error(`Failed to showOptionalInputMethods: ${JSON.stringify(err)}`);
3204e41f4b71Sopenharmony_ci})
3205e41f4b71Sopenharmony_ci```
3206e41f4b71Sopenharmony_ci
3207e41f4b71Sopenharmony_ci### listInputMethod<sup>(deprecated)</sup>
3208e41f4b71Sopenharmony_ci
3209e41f4b71Sopenharmony_cilistInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;): void
3210e41f4b71Sopenharmony_ci
3211e41f4b71Sopenharmony_ciObtains a list of installed input methods. This API uses an asynchronous callback to return the result.
3212e41f4b71Sopenharmony_ci
3213e41f4b71Sopenharmony_ci> **NOTE**
3214e41f4b71Sopenharmony_ci>
3215e41f4b71Sopenharmony_ci> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getInputMethods](#getinputmethods9) instead.
3216e41f4b71Sopenharmony_ci
3217e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
3218e41f4b71Sopenharmony_ci
3219e41f4b71Sopenharmony_ci**Parameters**
3220e41f4b71Sopenharmony_ci
3221e41f4b71Sopenharmony_ci| Name  | Type                                              | Mandatory| Description                  |
3222e41f4b71Sopenharmony_ci| -------- | -------------------------------------------------- | ---- | ---------------------- |
3223e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;Array<[InputMethodProperty](#inputmethodproperty8)>&gt; | Yes  | Callback used to return the list of installed input methods.|
3224e41f4b71Sopenharmony_ci
3225e41f4b71Sopenharmony_ci**Example**
3226e41f4b71Sopenharmony_ci
3227e41f4b71Sopenharmony_ci```ts
3228e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3229e41f4b71Sopenharmony_ci
3230e41f4b71Sopenharmony_ciinputMethodSetting.listInputMethod((err: BusinessError, data: Array<inputMethod.InputMethodProperty>) => {
3231e41f4b71Sopenharmony_ci  if (err) {
3232e41f4b71Sopenharmony_ci    console.error(`Failed to listInputMethod: ${JSON.stringify(err)}`);
3233e41f4b71Sopenharmony_ci    return;
3234e41f4b71Sopenharmony_ci  }
3235e41f4b71Sopenharmony_ci  console.log('Succeeded in listing inputMethod.');
3236e41f4b71Sopenharmony_ci });
3237e41f4b71Sopenharmony_ci```
3238e41f4b71Sopenharmony_ci
3239e41f4b71Sopenharmony_ci### listInputMethod<sup>(deprecated)</sup>
3240e41f4b71Sopenharmony_ci
3241e41f4b71Sopenharmony_cilistInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
3242e41f4b71Sopenharmony_ci
3243e41f4b71Sopenharmony_ciObtains a list of installed input methods. This API uses a promise to return the result.
3244e41f4b71Sopenharmony_ci
3245e41f4b71Sopenharmony_ci> **NOTE**
3246e41f4b71Sopenharmony_ci>
3247e41f4b71Sopenharmony_ci> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getInputMethods](#getinputmethods9-1) instead.
3248e41f4b71Sopenharmony_ci
3249e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
3250e41f4b71Sopenharmony_ci
3251e41f4b71Sopenharmony_ci**Return value**
3252e41f4b71Sopenharmony_ci
3253e41f4b71Sopenharmony_ci| Type                                                       | Description                  |
3254e41f4b71Sopenharmony_ci| ----------------------------------------------------------- | ---------------------- |
3255e41f4b71Sopenharmony_ci| Promise<Array<[InputMethodProperty](#inputmethodproperty8)>> | Promise used to return the list of installed input methods.|
3256e41f4b71Sopenharmony_ci
3257e41f4b71Sopenharmony_ci**Example**
3258e41f4b71Sopenharmony_ci
3259e41f4b71Sopenharmony_ci```ts
3260e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3261e41f4b71Sopenharmony_ci
3262e41f4b71Sopenharmony_ciinputMethodSetting.listInputMethod().then((data: Array<inputMethod.InputMethodProperty>) => {
3263e41f4b71Sopenharmony_ci  console.log('Succeeded in listing inputMethod.');
3264e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
3265e41f4b71Sopenharmony_ci  console.error(`Failed to listInputMethod: ${JSON.stringify(err)}`);
3266e41f4b71Sopenharmony_ci})
3267e41f4b71Sopenharmony_ci```
3268e41f4b71Sopenharmony_ci
3269e41f4b71Sopenharmony_ci### displayOptionalInputMethod<sup>(deprecated)</sup>
3270e41f4b71Sopenharmony_ci
3271e41f4b71Sopenharmony_cidisplayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void
3272e41f4b71Sopenharmony_ci
3273e41f4b71Sopenharmony_ciDisplays a dialog box for selecting an input method. This API uses an asynchronous callback to return the result.
3274e41f4b71Sopenharmony_ci
3275e41f4b71Sopenharmony_ci> **NOTE**
3276e41f4b71Sopenharmony_ci>
3277e41f4b71Sopenharmony_ci> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [showOptionalInputMethods()](#showoptionalinputmethods9) instead.
3278e41f4b71Sopenharmony_ci
3279e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
3280e41f4b71Sopenharmony_ci
3281e41f4b71Sopenharmony_ci**Parameters**
3282e41f4b71Sopenharmony_ci
3283e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
3284e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
3285e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
3286e41f4b71Sopenharmony_ci
3287e41f4b71Sopenharmony_ci**Example**
3288e41f4b71Sopenharmony_ci
3289e41f4b71Sopenharmony_ci```ts
3290e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3291e41f4b71Sopenharmony_ci
3292e41f4b71Sopenharmony_ciinputMethodSetting.displayOptionalInputMethod((err: BusinessError) => {
3293e41f4b71Sopenharmony_ci  if (err) {
3294e41f4b71Sopenharmony_ci    console.error(`Failed to displayOptionalInputMethod: ${JSON.stringify(err)}`);
3295e41f4b71Sopenharmony_ci    return;
3296e41f4b71Sopenharmony_ci  }
3297e41f4b71Sopenharmony_ci  console.log('Succeeded in displaying optionalInputMethod.');
3298e41f4b71Sopenharmony_ci});
3299e41f4b71Sopenharmony_ci```
3300e41f4b71Sopenharmony_ci
3301e41f4b71Sopenharmony_ci### displayOptionalInputMethod<sup>(deprecated)</sup>
3302e41f4b71Sopenharmony_ci
3303e41f4b71Sopenharmony_cidisplayOptionalInputMethod(): Promise&lt;void&gt;
3304e41f4b71Sopenharmony_ci
3305e41f4b71Sopenharmony_ciDisplays a dialog box for selecting an input method. This API uses a promise to return the result.
3306e41f4b71Sopenharmony_ci
3307e41f4b71Sopenharmony_ci> **NOTE**
3308e41f4b71Sopenharmony_ci>
3309e41f4b71Sopenharmony_ci> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [showOptionalInputMethods()](#showoptionalinputmethods9-1) instead.
3310e41f4b71Sopenharmony_ci
3311e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.InputMethodFramework
3312e41f4b71Sopenharmony_ci
3313e41f4b71Sopenharmony_ci**Return value**
3314e41f4b71Sopenharmony_ci
3315e41f4b71Sopenharmony_ci| Type| Description|
3316e41f4b71Sopenharmony_ci| -------- | -------- |
3317e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
3318e41f4b71Sopenharmony_ci
3319e41f4b71Sopenharmony_ci**Example**
3320e41f4b71Sopenharmony_ci
3321e41f4b71Sopenharmony_ci```ts
3322e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3323e41f4b71Sopenharmony_ci
3324e41f4b71Sopenharmony_ciinputMethodSetting.displayOptionalInputMethod().then(() => {
3325e41f4b71Sopenharmony_ci  console.log('Succeeded in displaying optionalInputMethod.');
3326e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
3327e41f4b71Sopenharmony_ci  console.error(`Failed to displayOptionalInputMethod: ${JSON.stringify(err)}`);
3328e41f4b71Sopenharmony_ci})
3329e41f4b71Sopenharmony_ci```
3330