> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The **InputMethodCommon** module provides the common attributes defined by the input method framework.
| type | string | Yes | Listening type.<br>The value **selectByRange** indicates the selection-by-range event.|
| callback | Callback<[Range](./js-apis-inputmethod-InputMethodCommon.md#range)> | Yes | Callback used to return the range of the text to be selected.<br>Your application needs to select the text in the returned range in the text box.|
| type | string | Yes | Listening type.<br>The value **selectByMovement** indicates the selection-by-cursor-movement event.|
| callback | Callback<[Movement](./js-apis-inputmethod-InputMethodCommon.md#movement)> | Yes | Callback used to return the range of the text to be selected.<br>Your application needs to select the text in the returned range in the text box.|
| type | string | Yes | Listening type.<br>The value **selectByMovement** indicates the selection-by-cursor-movement event.|
**Example**
```js
inputMethodController.off('selectByMovement');
```
## InputMethodSetting<sup>8+</sup>
In the following API examples, you must first use [getSetting](#inputmethodgetsetting9) to obtain an **InputMethodSetting** instance, and then call the APIs using the obtained instance.
| range | [Range](./js-apis-inputmethod-InputMethodCommon.md#range) | Yes | Range of the selected text. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the selection event is sent, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
| movement | [Movement](./js-apis-inputmethod-InputMethodCommon.md#movement) | Yes | Direction in which the cursor moves when the text is selected. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the selection event is sent, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
| callback | AsyncCallback<number> | Yes | Callback used to return the result. If the text index is obtained, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
| Error Code ID| Error Message |
| -------- | ------------------------------ |
| 401 | parameter error. |
| 12800003 | Input method client error. |
| 12800006 | Input method controller error. |
**Example**
```js
inputClient.getTextIndexAtCursor((err,index)=>{
if(err!==undefined){
console.error('Failed to getTextIndexAtCursor: ${err.message}');
return;
}
console.info('Succeeded in getTextIndexAtCursor: '+index);
});
```
### getTextIndexAtCursor<sup>10+</sup>
getTextIndexAtCursor(): Promise<number>
Obtains the index of the text where the cursor is located. This API uses a promise to return the result.