HTML enterkeyhint Attribute
The HTML enterkeyhint global attribute provides a hint about the action label or icon that should appear on the Enter key of a virtual keyboard. It can help make text entry more intuitive by indicating actions such as Enter, Done, Go, Next, Previous, Search, or Send.
Syntax
The enterkeyhint attribute is assigned a keyword describing the action that the Enter key should represent on a virtual keyboard.
<input type="search" enterkeyhint="search">
The browser can use the hint to display an appropriate label or icon on the virtual keyboard's Enter key.
Attribute Values
The enterkeyhint attribute is an enumerated attribute with seven supported values.
| Value | Typical Purpose |
|---|---|
enter |
Indicates an Enter or Return action, such as inserting a new line. |
done |
Indicates that text entry is complete and the input method can be closed. |
go |
Indicates an action that takes the user to a target associated with the entered text. |
next |
Indicates moving to the next text-entry field. |
previous |
Indicates moving to the previous text-entry field. |
search |
Indicates performing a search using the entered text. |
send |
Indicates sending or delivering the entered text. |
Global Attribute
The enterkeyhint attribute is a global attribute. It is useful on form controls that accept text and on editable content where a virtual keyboard may be displayed.
<input type="text" enterkeyhint="next">
<textarea enterkeyhint="send"></textarea>
<p contenteditable="true" enterkeyhint="done">Editable text</p>
Although it is a global attribute, it only has a practical effect when the browser is accepting editable text and presenting an applicable virtual keyboard.
Virtual Keyboards
The enterkeyhint attribute is designed for virtual keyboards, such as those displayed on phones and tablets. The browser and operating system determine the actual label or icon shown.
<label for="search">Search:</label>
<input type="search" id="search" name="search" enterkeyhint="search">
On a supported device, the Enter key may display a word such as Search or an icon representing a search action. The exact appearance can vary by browser, operating system, language, and keyboard.
enterkeyhint and inputmode
The enterkeyhint and inputmode attributes both provide hints for virtual keyboards, but they serve different purposes.
| Attribute | Purpose |
|---|---|
enterkeyhint |
Suggests the action label or icon for the Enter key. |
inputmode |
Suggests the type of virtual keyboard that should be displayed. |
<input type="text"
inputmode="numeric"
enterkeyhint="done">
In this example, inputmode="numeric" suggests a numeric keyboard, while enterkeyhint="done" suggests that the Enter key indicate completion.
Browser Behavior
The enterkeyhint attribute is a hint rather than a command. The browser determines how the requested action is represented on the user's virtual keyboard.
If enterkeyhint is omitted or its value is unsupported, the browser can use contextual information such as the control's type, inputmode, or pattern attributes to choose an appropriate Enter key label or icon.
The attribute changes the presentation of the virtual keyboard's Enter key; it does not by itself define what happens when the user activates that key.
Common Mistakes
Do not assume that enterkeyhint changes the behavior of the Enter key. It provides a presentation hint for the virtual keyboard rather than defining an action.
Do not expect the attribute to visibly change a physical keyboard. Its purpose is to influence the Enter key displayed by supported virtual keyboards.
Do not rely on a specific word or icon being displayed. The browser, operating system, keyboard, and user's language can affect how the hint is presented.
Browser Support
Baseline: Widely available indicates a feature has been supported by core browsers for at least 30 months. At this stage, the feature is considered stable and safe for most websites to use without needing to worry about compatibility issues or fallbacks, as it is supported by the vast majority of users' devices and browser versions.
The enterkeyhint global attribute is widely supported in current core browsers. The exact appearance of the virtual keyboard action key can vary by browser, operating system, language, and device.
Checking Browser Support
For current browser compatibility information, visit Can I Use? . Search for the HTML element or attribute you want to check. You can also narrow your search by entering an element name and attribute name separated by a colon. Search results can include related HTML features, element attributes, input types, APIs, and other technologies, so select the result that most closely matches the feature you are checking.
Try the enterkeyhint Attribute
The example uses several enterkeyhint values. Open the example on a device with a virtual keyboard, select each field, and compare the Enter key that is displayed.
Summary
The HTML enterkeyhint global attribute provides a hint about the action label or icon displayed on the Enter key of a virtual keyboard. Its supported values are enter, done, go, next, previous, search, and send. The attribute affects the presentation of the virtual keyboard and does not by itself define what happens when the Enter key is activated.
