summaryrefslogtreecommitdiff
path: root/devdocs/html/global_attributes%2Fenterkeyhint.html
blob: 83e0237c2303ff89ad3a40679bbd9b8c4fe9803e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<header><h1>enterkeyhint</h1></header><div class="section-content"><p> The <code>enterkeyhint</code> <a href="../global_attributes">global attribute</a> is an <a href="https://developer.mozilla.org/en-US/docs/Glossary/Enumerated">enumerated</a> attribute defining what action label (or icon) to present for the enter key on virtual keyboards. </p></div>
<h2 id="try_it">Try it</h2>
<div class="section-content"><iframe class="interactive is-tabbed-shorter-height" height="200" src="https://interactive-examples.mdn.mozilla.net/pages/tabbed/attribute-enterkeyhint.html" title="MDN Web Docs Interactive Example" loading="lazy"></iframe></div>
<h2 id="description">Description</h2>
<div class="section-content">
<p> <a href="https://developer.mozilla.org/en-US/docs/Learn/Forms">Form controls</a> (such as <a href="../element/textarea"><code>&lt;textarea&gt;</code></a> or <a href="../element/input"><code>&lt;input&gt;</code></a> elements) or elements using <a href="contenteditable"><code>contenteditable</code></a> can specify an <a href="inputmode"><code>inputmode</code></a> attribute to control what kind of virtual keyboard will be used. To further improve the user's experience, the enter key can be customized specifically by providing an <code>enterkeyhint</code> attribute indicating how the enter key should be labeled (or which icon should be shown). The enter key usually represents what the user should do next; typical actions are: sending text, inserting a new line, or searching. </p> <p> If no <code>enterkeyhint</code> attribute is provided, the user agent might use contextual information from the <a href="inputmode"><code>inputmode</code></a>, <a href="../element/input#input_types"><code>type</code></a>, or <a href="../element/input#pattern"><code>pattern</code></a> attributes to display a suitable enter key label (or icon). </p>
</div>
<h3 id="values">Values</h3>
<div class="section-content">
<p>The <code>enterkeyhint</code> attribute is an <a href="https://developer.mozilla.org/en-US/docs/Glossary/Enumerated">enumerated</a> attribute and only accepts the following values:</p> <figure class="table-container"><div class="_table"><table class="no-markdown"> <thead> <tr> <th>Value</th> <th>Description</th> <th>Example label (depends on user agent and user language)</th> </tr> </thead> <tbody> <tr> <td><code>enterkeyhint="enter"</code></td> <td>Typically inserting a new line.</td> <td><kbd>↵</kbd></td> </tr> <tr> <td><code>enterkeyhint="done"</code></td> <td> Typically meaning there is nothing more to input and the input method editor (IME) will be closed. </td> <td><kbd>Done</kbd></td> </tr> <tr> <td><code>enterkeyhint="go"</code></td> <td>Typically meaning to take the user to the target of the text they typed.</td> <td><kbd>Open</kbd></td> </tr> <tr> <td><code>enterkeyhint="next"</code></td> <td>Typically taking the user to the next field that will accept text.</td> <td><kbd>Next</kbd></td> </tr> <tr> <td><code>enterkeyhint="previous"</code></td> <td>Typically taking the user to the previous field that will accept text.</td> <td><kbd>Previous</kbd></td> </tr> <tr> <td><code>enterkeyhint="search"</code></td> <td> Typically taking the user to the results of searching for the text they have typed. </td> <td><kbd>Search</kbd></td> </tr> <tr> <td><code>enterkeyhint="send"</code></td> <td>Typically delivering the text to its target.</td> <td><kbd>Send</kbd></td> </tr> </tbody> </table></div></figure>
</div>
<h2 id="specifications">Specifications</h2>
<div class="_table"><table class="standard-table">
<thead><tr><th scope="col">Specification</th></tr></thead>
<tbody><tr><td><a href="https://html.spec.whatwg.org/multipage/interaction.html#attr-enterkeyhint">HTML Standard <br><small># attr-enterkeyhint</small></a></td></tr></tbody>
</table></div>
<h2 id="browser_compatibility">Browser compatibility</h2>
<div class="_table"><table>
<thead>
<tr id="bct-browser-type">
<th></th>
<th colspan="6">Desktop</th>
<th colspan="6">Mobile</th>
</tr>
<tr id="bct-browsers">
<th></th>
<th>Chrome</th>
<th>Edge</th>
<th>Firefox</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
<th>WebView Android</th>
<th>Chrome Android</th>
<th>Firefox for Android</th>
<th>Opera Android</th>
<th>Safari on IOS</th>
<th>Samsung Internet</th>
</tr>
</thead>
<tbody><tr>
<th><code>enterkeyhint</code></th>
<td class="bc-supports-yes">77</td>
<td class="bc-supports-yes">79</td>
<td class="bc-supports-yes">94</td>
<td class="bc-supports-no">No</td>
<td class="bc-supports-yes">66</td>
<td class="bc-supports-yes">13.1</td>
<td class="bc-supports-yes">77</td>
<td class="bc-supports-yes">77</td>
<td class="bc-supports-yes">94</td>
<td class="bc-supports-yes">57</td>
<td class="bc-supports-yes">13.4</td>
<td class="bc-supports-yes">12.0</td>
</tr></tbody>
</table></div>
<h2 id="see_also">See also</h2>
<div class="section-content"><ul> <li>
<a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/enterKeyHint"><code>HTMLElement.enterKeyHint</code></a> property reflecting this attribute</li> <li>
<a href="inputmode"><code>inputmode</code></a> global attribute</li> <li>
<a href="contenteditable"><code>contenteditable</code></a> global attribute</li> <li> <a href="../element/input#input_types"><code>type</code></a> and <a href="../element/input#pattern"><code>pattern</code></a> attributes on <a href="../element/input"><code>&lt;input&gt;</code></a> elements </li> </ul></div><div class="_attribution">
  <p class="_attribution-p">
    &copy; 2005&ndash;2023 MDN contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>
    <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint" class="_attribution-link">https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint</a>
  </p>
</div>