diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md index a11614d149bfd2db3c3b8370aeba57ea906f880d..3cd283c8f0d463fb603b5234260dafc69b8d49c0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @@ -173,6 +173,108 @@ stopInput(): Promise<boolean> console.info('stopInput isSuccess = ' + isSuccess); ``` +### showSoftKeyboard9+ ### + +showSoftKeyboard(callback: AsyncCallback<void>): void + +显示软键盘,使用callback异步回调。 + +**系统能力:** SystemCapability.MiscServices.InputMethodFramework + +**参数:** + +| 参数名 | 参数类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +InputMethodController.showSoftKeyboard((err) => { + if (err == undefined) { + console.error('showSoftKeyboard success'); + } else { + console.info('showSoftKeyboard failed : ' + JSON.stringify(err)); + } +}) +``` + + +### showSoftKeyboard9+ ### + +showSoftKeyboard(): Promise<void> + +显示软键盘,使用Promise异步回调。 + +**系统能力:** SystemCapability.MiscServices.InputMethodFramework + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +InputMethodController.showSoftKeyboard().then(async (err) => { + console.log('showSoftKeyboard success'); +}).catch((err) => { + console.log('showSoftKeyboard fail ' + JSON.stringify(err)); +}); +``` + +### hideSoftKeyboard9+ ### + +hideSoftKeyboard(callback: AsyncCallback<void>): void + +隐藏软键盘,使用callback异步回调。 + +**系统能力:** SystemCapability.MiscServices.InputMethodFramework + +**参数:** + +| 参数名 | 参数类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +InputMethodController.hideSoftKeyboard((err) => { + if (err == undefined) { + console.error('hideSoftKeyboard success'); + } else { + console.info('hideSoftKeyboard failed : ' + JSON.stringify(err)); + } +}) +``` + + +### hideSoftKeyboard9+ ### + +hideSoftKeyboard(): Promise<void> + +隐藏软键盘,使用Promise异步回调。 + +**系统能力:** SystemCapability.MiscServices.InputMethodFramework + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +InputMethodController.hideSoftKeyboard().then(async (err) => { + console.log('hideSoftKeyboard success'); +}).catch((err) => { + console.log('hideSoftKeyboard fail ' + JSON.stringify(err)); +}); +``` + ## InputMethodSetting8+ 下列API示例中都需使用[getInputMethodSetting](#inputmethodgetinputmethodcontroller)回调获取到InputMethodSetting实例,再通过此实例调用对应方法。