harmony 鸿蒙Class (WebKeyboardController)

  • 2025-06-12
  • 浏览 (4)

Class (WebKeyboardController)

控制自定义键盘的输入、删除、关闭等操作。示例代码参考onInterceptKeyboardAttach

说明:

  • 本模块接口从API version 12开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。

  • 示例效果请以真机运行为准,当前IDE预览器不支持。

constructor12+

constructor()

WebKeyboardController的构造函数。

系统能力: SystemCapability.Web.Webview.Core

insertText12+

insertText(text: string): void

Web输入框中插入字符。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
text string 向Web输入框插入字符。

deleteForward12+

deleteForward(length: number): void

从后往前删除Web输入框中指定长度的字符。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
length number 从后往前删除Web输入框中指定长度的字符。
参数无取值范围,当参数值大于字符长度时,默认删除光标前面所有字符;参数值为负数时,不执行删除操作。

deleteBackward12+

deleteBackward(length: number): void

从前往后删除Web输入框中指定长度的字符。

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
length number 从前往后删除Web输入框中指定长度的字符。
参数无取值范围,当参数值大于字符长度时,默认删除光标后面所有字符;参数值为负数时,不执行删除操作。

sendFunctionKey12+

sendFunctionKey(key: number): void

插入功能按键,目前仅支持Enter键类型,取值见EnterKeyType

系统能力: SystemCapability.Web.Webview.Core

参数:

参数名 类型 必填 说明
key number 向Web输入框传递功能键,目前仅支持Enter键。

close12+

close(): void

关闭自定义键盘。

系统能力: SystemCapability.Web.Webview.Core

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkWeb(方舟Web)

harmony 鸿蒙ArkWeb_AnyNativeAPI

harmony 鸿蒙ArkWeb_ComponentAPI

harmony 鸿蒙ArkWeb_ControllerAPI

harmony 鸿蒙ArkWeb_CookieManagerAPI

harmony 鸿蒙ArkWeb_JavaScriptBridgeData

harmony 鸿蒙ArkWeb_JavaScriptObject

harmony 鸿蒙ArkWeb_JavaScriptValueAPI

harmony 鸿蒙ArkWeb_ProxyMethod

harmony 鸿蒙ArkWeb_ProxyMethodWithResult

0  赞