Skip to content

The enterkeyhint Attribute

Global Attribute

The enterkeyhint attribute customizes the label and icon of the Enter key on virtual keyboards (mobile devices). It provides visual context for what action will be performed when the user presses Enter, improving the mobile user experience.

<element enterkeyhint="value">Content</element>
ValueLabelIconUse Case
enterEnter / ReturnDefault, new line
doneDoneComplete task/form
goGoNavigate/submit
nextNextMove to next field
previousPreviousMove to previous field
searchSearch🔍Perform search
sendSendSend message/email
Result
Result
Result
Result

Choose the value that matches what happens when Enter is pressed:

<!-- Search field → "search" -->
<input type="search" enterkeyhint="search">
<!-- Chat message → "send" -->
<input type="text" enterkeyhint="send">
<!-- Multi-step form → "next" -->
<input type="text" enterkeyhint="next">
<!-- Final form field → "done" -->
<input type="email" enterkeyhint="done">
<!-- URL input → "go" -->
<input type="url" enterkeyhint="go">
<input
type="text"
enterkeyhint="send"
onkeypress="if(event.key==='Enter') sendMessage()">
<!-- Step 1 -->
<input enterkeyhint="next" id="step1">
<!-- Step 2 -->
<input enterkeyhint="next" id="step2">
<!-- Final step -->
<input enterkeyhint="done" id="step3">
<input
type="search"
enterkeyhint="search"
inputmode="search"
autocomplete="off"
placeholder="Search...">
PlatformSupportNotes
iOS Safari13.4+Full support
Android Chrome77+Full support
Desktop browsersIgnoredNo virtual keyboard
  • search: “Search” with magnifying glass
  • send: “Send” with arrow
  • next: “Next” with arrow
  • done: “Done” text
  • go: “Go” with arrow
  • search: Magnifying glass icon
  • send: Arrow icon
  • next: Arrow icon
  • done: Checkmark or “Done”
  • go: Arrow icon
const input = document.getElementById('myInput');
// Set enterkeyhint
input.enterKeyHint = 'send';
input.setAttribute('enterkeyhint', 'send');
// Get current value
console.log(input.enterKeyHint); // "send"
// Handle Enter key
input.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
// Perform action based on hint
if (input.enterKeyHint === 'send') {
sendMessage();
} else if (input.enterKeyHint === 'search') {
performSearch();
}
}
});