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
67
68
69
70
71
72
73
74
|
<header><h1>accesskey</h1></header><div class="section-content"><p>The <code>accesskey</code> <a href="../global_attributes">global attribute</a> provides a hint for generating a keyboard shortcut for the current element. The attribute value must consist of a single printable character (which includes accented and other characters that can be generated by the keyboard).</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-accesskey.html" title="MDN Web Docs Interactive Example" loading="lazy"></iframe> <div class="notecard note" id="sect1"> <p><strong>Note:</strong> In the WHATWG spec, it says you can specify multiple space-separated characters, and the browser will use the first one it supports. However, this does not work in most browsers. IE/Edge uses the first one it supports without problems, provided there are no conflicts with other commands.</p> </div> <p>The way to activate the accesskey depends on the browser and its platform:</p> <figure class="table-container"><div class="_table"><table class="standard-table"> <tbody> <tr> <th></th> <th>Windows</th> <th>Linux</th> <th>Mac</th> </tr> <tr> <th>Firefox</th> <td colspan="2">
<kbd>Alt</kbd> + <kbd>Shift</kbd> + <kbd><em>key</em></kbd>
</td> <td> <ul> <li> Firefox 57+: <kbd>Control</kbd> + <kbd>Option</kbd> + <kbd><em>key</em></kbd> or <kbd>Control</kbd> + <kbd>Alt</kbd> + <kbd><em>key</em></kbd> </li> <li> Firefox 14-56: <kbd>Control</kbd> + <kbd>Alt</kbd> + <kbd><em>key</em></kbd> </li> <li> Firefox 13 or older: <kbd>Control</kbd> + <kbd><em>key</em></kbd> </li> </ul> </td> </tr> <tr> <th>Edge</th> <td rowspan="2">
<kbd>Alt</kbd> + <kbd><em>key</em></kbd>
</td> <td rowspan="2"> <kbd>Control</kbd> + <kbd>Option</kbd> + <kbd><em>key</em></kbd><br>or <kbd>Control</kbd> + <kbd>Option</kbd> + <kbd>Shift</kbd> + <kbd><em>key</em></kbd> </td> <td>n/a</td> </tr> <tr> <th>Google Chrome</th> <td>
<kbd>Control</kbd> + <kbd>Option</kbd> + <kbd><em>key</em></kbd>
</td> </tr> <tr> <th>Safari</th> <td colspan="2">n/a</td> <td>
<kbd>Control</kbd> + <kbd>Option</kbd> + <kbd><em>key</em></kbd>
</td> </tr> <tr> <th>Opera 15+</th> <td colspan="2">
<kbd>Alt</kbd> + <kbd><em>key</em></kbd>
</td> <td>
<kbd>Control</kbd> + <kbd>Alt</kbd> + <kbd><em>key</em></kbd>
</td> </tr> <tr> <th>Opera 12</th> <td colspan="3"> <kbd>Shift</kbd> + <kbd>Esc</kbd> opens a list of available accesskeys. Choose an item from the list by pressing the <kbd><em>key</em></kbd>. </td> </tr> </tbody> </table></div></figure>
</div>
<h2 id="accessibility_concerns">Accessibility concerns</h2>
<div class="section-content">
<p>In addition to poor browser support, there are numerous concerns with the <code>accesskey</code> attribute:</p> <ul> <li>An <code>accesskey</code> value can conflict with a system or browser keyboard shortcut, or assistive technology functionality. What may work for one combination of operating system, assistive technology, and browser may not work with other combinations.</li> <li>Certain <code>accesskey</code> values may not be present on certain keyboards, especially when internationalization is a concern. So adapting to specific languages could cause further problems.</li> <li>
<code>accesskey</code> values that rely on numbers may be confusing to individuals experiencing cognitive concerns, where the number doesn't have a logical association with the functionality it triggers.</li> <li>Informing the user that <code>accesskey</code>s are present, so that they are aware of the functionality. If the system lacks a method of notifying the user about this feature, the user might accidentally activate <code>accesskey</code>s.</li> </ul> <p>Because of these issues, it is generally advised not to use <code>accesskey</code>s for most general-purpose websites and web apps.</p> <ul> <li><a href="https://webaim.org/techniques/keyboard/accesskey#spec" target="_blank">WebAIM: Keyboard Accessibility - Accesskey</a></li> </ul>
</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#the-accesskey-attribute">HTML Standard <br><small># the-accesskey-attribute</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>accesskey</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">15</td>
<td class="bc-supports-yes">≤4</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">≤3.2</td>
<td class="bc-supports-yes">1.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/accessKey"><code>HTMLElement.accessKey</code></a></li> <li><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/accessKeyLabel"><code>HTMLElement.accessKeyLabel</code></a></li> <li>All <a href="../global_attributes">global attributes</a>.</li> <li><a href="https://www.w3.org/TR/wai-aria-1.1/#aria-keyshortcuts" target="_blank"><code>aria-keyshortcuts</code></a></li> </ul></div><div class="_attribution">
<p class="_attribution-p">
© 2005–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/accesskey" class="_attribution-link">https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey</a>
</p>
</div>
|