accesskey
The accesskey
global attribute 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).
Note: 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.
The way to activate the accesskey depends on the browser and its platform:
Windows | Linux | Mac | |
---|---|---|---|
Firefox | Alt + Shift + key | On Firefox 57 or newer: Control + Option + key or Control + Alt + key On Firefox 14 or newer: Control + Alt + key On Firefox 13 or older: Control + key | |
Internet Explorer |
Alt + key Alt + Shift + key | N/A | |
Edge | N/A | Control + Option + key Control + Option + Shift + key | |
Google Chrome | Alt + key | ||
Safari | N/A | ||
Opera 15+ | Alt + key | Control + Alt + key | |
Opera 12 | Shift + Esc opens a contents list which are accessible by accesskey, then, can choose an item by pressing key |
Accessibility concerns
In addition to poor browser support, there are numerous concerns with the accesskey
attribute:
- An
accesskey
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. - Certain
accesskey
values may not be present on certain keyboards, especially when internationalization is a concern. So adapting to specific languages could cause further problems. -
accesskey
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. - Informing the user that
accesskey
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 activateaccesskey
s.
Because of these issues, it is generally advised not to use accesskey
s for most general-purpose websites and web apps.
Specifications
Specification |
---|
HTML Standard (HTML) # the-accesskey-attribute |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
accesskey |
Yes |
12 |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
See also
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey