enterKeyHint

The enterkeyhint attribute in HTML offers a suggestion for the action that should take place when the Enter key is pressed in a form input. This improves user experience, especially on virtual keyboards.

enterkeyhint attribute

The enterkeyhint attribute in HTML offers guidance to the browser or user agent regarding the action to be taken when the "Enter" key is pressed while an input field is active. It is mainly applied to <input> and <textarea> elements.

Syntax

index.html
<element enterkeyhint="done|enter|go|next|previous|search|send">

Example

index.html
<input type="text" enterkeyhint="search" placeholder="Search here">

Definition and Usage

The enterkeyhint attribute lets you customize the appearance of the "Enter" key on a virtual keyboard.

Applies to

The enterkeyhint attribute is a global attribute that can be applied to any HTML element that is editable.

ElementsAttribute
All HTML elementsenterkeyhint

Attributes values

ValueDescription
doneThe enter key says "Done"
enterThe enter key says "enter"
goThe enter key says "go"
nextThe enter key says "next"
previousThe enter key says "previous"
searchThe enter key says "search"
sendThe enter key says "send"

In this example, when the input is focused, the virtual keyboard will display "Search" on the Enter key.

Conclusion

The enterkeyhint attribute allows customization of the "Enter" key's label on virtual keyboards, improving user experience. It can be applied to any editable HTML element, such as <input> and <textarea>. By setting values like "search," "send," or "next," developers can guide users' interactions with form fields.