• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Class (WebKeyboardController)
2<!--Kit: ArkWeb-->
3<!--Subsystem: Web-->
4<!--Owner: @zourongchun-->
5<!--Designer: @zhufenghao-->
6<!--Tester: @ghiker-->
7<!--Adviser: @HelloCrease-->
8
9控制自定义键盘的输入、删除、关闭等操作。示例代码参考[onInterceptKeyboardAttach](./arkts-basic-components-web-events.md#oninterceptkeyboardattach12)。
10
11> **说明:**
12>
13> - 该组件首批接口从API version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
14>
15> - 本Class首批接口从API version 12开始支持。
16>
17> - 示例效果请以真机运行为准,当前DevEco Studio预览器不支持。
18
19## constructor<sup>12+</sup>
20
21constructor()
22
23WebKeyboardController的构造函数。
24
25**系统能力:** SystemCapability.Web.Webview.Core
26
27## insertText<sup>12+</sup>
28
29insertText(text: string): void
30
31Web输入框中插入字符。
32
33**系统能力:** SystemCapability.Web.Webview.Core
34
35**参数:**
36
37| 参数名 | 类型 | 必填 | 说明 |
38| ------ | -------- | ---- | --------------------- |
39| text | string | 是 | 向Web输入框插入字符。 |
40
41## deleteForward<sup>12+</sup>
42
43deleteForward(length: number): void
44
45从后往前删除Web输入框中指定长度的字符。
46
47**系统能力:** SystemCapability.Web.Webview.Core
48
49**参数:**
50
51| 参数名 | 类型 | 必填 | 说明                                                                                                   |
52| ------ | -------- | ---- |------------------------------------------------------------------------------------------------------|
53| length | number   | 是   | 从后往前删除Web输入框中指定长度的字符。<br>取值范围:[-2147483648 , 2147483647],当参数值大于字符长度时,默认删除光标前面所有字符;参数值为负数时,不执行删除操作。 |
54
55## deleteBackward<sup>12+</sup>
56
57deleteBackward(length: number): void
58
59从前往后删除Web输入框中指定长度的字符。
60
61**系统能力:** SystemCapability.Web.Webview.Core
62
63**参数:**
64
65| 参数名 | 类型 | 必填 | 说明                 |
66| ------ | -------- | ---- | ------------------------ |
67| length | number   | 是   | 从前往后删除Web输入框中指定长度的字符。<br>取值范围:[-2147483648 , 2147483647],当参数值大于字符长度时,默认删除光标后面所有字符;参数值为负数时,不执行删除操作。 |
68
69## sendFunctionKey<sup>12+</sup>
70
71sendFunctionKey(key: number): void
72
73插入功能按键,目前仅支持Enter键类型,取值见[EnterKeyType](../apis-ime-kit/js-apis-inputmethod.md#enterkeytype10)。
74
75**系统能力:** SystemCapability.Web.Webview.Core
76
77**参数:**
78
79| 参数名 | 类型 | 必填 | 说明                                   |
80| ------ | -------- | ---- | ------------------------------------------ |
81| key    | number   | 是   | 向Web输入框传递功能键,目前仅支持Enter键。 |
82
83## close<sup>12+</sup>
84
85close(): void
86
87关闭自定义键盘。
88
89**系统能力:** SystemCapability.Web.Webview.Core