enterkeyhint
Changes the label or icon of the Enter key on the on-screen keyboard, for example to “Search”, “Send” or “Next”.
- Applies to
- Form fields
<input>and<textarea>, and elements withcontenteditable
Example
#<style>
#chat { list-style: none; margin: 0 0 12px; padding: 0; }
#chat li {
width: fit-content;
margin-bottom: 6px;
padding: 6px 10px;
border-radius: 10px;
background: #1f1f23;
}
</style>
<ul id="chat">
<li>Mentor: How is the for loop exercise going?</li>
</ul>
<form onsubmit="
event.preventDefault();
const item = document.createElement('li');
item.textContent = 'You: ' + this.elements.message.value;
document.getElementById('chat').append(item);
this.reset();
">
<input name="message" enterkeyhint="send" required
placeholder="Type a reply and press Enter" aria-label="Message to your mentor">
</form>On a phone the Enter key turns into “Send”. The sending itself is handled by the form: Enter in its only field triggers the submit event, and the script appends the message to the chat. On a computer Enter works the same way, just without the change in the key’s look.
Definition and usage
#The enterkeyhint attribute decides what the Enter key looks like on the on-screen keyboard of a phone or tablet. Instead of a generic arrow, the key can show a label or an icon that announces what will happen when it is pressed: “Search” in a search engine, “Send” in a chat, “Next” in a form with several fields.
The attribute changes only the look of the key, not what it does. When pressed, the page receives an ordinary Enter key event, so you provide whatever is supposed to happen. In a form with a single-line field, Enter submits the form without extra code, but moving to the next field or sending a message from a <textarea> requires a script.
On a computer with a physical keyboard you will see no difference. The exact label or icon is chosen by the phone’s system, so the same value may look slightly different on an iPhone and on Android.
Syntax
#<element enterkeyhint="enter | done | go | next | previous | search | send">…</element>Values
#enter
A standard Enter, which most often inserts a new line.done
Typing is finished. It usually means the keyboard can hide.go
Go to the destination, for example to the typed address.next
Move to the next form field.previous
Go back to the previous form field.search
Search for the typed phrase.send
Send a message, for example in a chat or a comment.
Browser support
#Widely available · since 2021
Works in all modern browsers, phones included. You can use it without worry.
- Chrome
- Edge
- Firefox
- Safari
Good practices
#- Match the value to what Enter will really do. A “Send” key that only inserts a new line is misleading.
- In a
<textarea>, Enter adds a new line by default. If it should send the message, handle thekeydownevent and only then setenterkeyhint="send".
Related entries
#- inputmodeHints which on-screen keyboard to show: digits, digits with a decimal separator, a phone pad, an email keyboard, or none.
- autocapitalizeTells the on-screen keyboard when to capitalize: never, at the start of a sentence, at the start of a word, or always.
- <input>A form field: text, email, password, number, date, slider, checkbox, file and many more.
- <textarea>A multi-line text field for longer input: messages, reviews, descriptions.
- <form>A form that collects data from the user and sends it to a given address.
Spotted a mistake or missing an example? Write to us.