enterkeyhint

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since November 2021.

全局属性 enterkeyhint 是一个枚举属性,定义虚拟键盘上回车键的操作标签(或图标)。

尝试一下

描述

表单控件(如 <textarea><input> 元素)或使用 contenteditable 的元素可以指定 inputmode 属性来控制使用哪种虚拟键盘。为了进一步改善用户体验,可以通过提供 enterkeyhint 属性来特别定制回车键,该属性指明回车键应如何标记(或应显示哪个图标)。回车键通常代表用户下一步要做的操作;典型的操作有:发送文本、插入新行或搜索。

如果没有提供 enterkeyhint 属性,用户代理可能会使用 inputmodetypepattern 属性中的上下文信息来显示合适的回车键标签(或图标)。

enterkeyhint 属性是一个枚举属性,只接受以下值:

描述 示例标签(取决于用户代理和用户语言)
enterkeyhint="enter" 通常是插入新行。 return
enterkeyhint="done" 通常意味着没有其他输入内容,输入法编辑器(IME)将关闭。 done
enterkeyhint="go" 通常是指将用户带到他们键入文本的目标位置。 go🡢
enterkeyhint="next" 通常会将用户带到下一个可接受文本的字段。 next
enterkeyhint="previous" 通常会将用户带到上一个可接受文本的字段。 return
enterkeyhint="search" 通常会将用户带到他们输入的文本的搜索结果中。 search🔍
enterkeyhint="send" 通常是将文本传递给目标。 send

规范

Specification
HTML
# attr-enterkeyhint

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
enterkeyhint

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见