The HTML accesskey attribute
The HTML accesskey attribute suggests a keyboard shortcut that focuses or activates an element, e.g. accesskey="s". The exact key combination varies by browser and operating system (often Alt, or Alt+Shift, plus the key). It is a global attribute, but conflicts with browser and assistive-tech shortcuts make it unreliable.
Overview
The accesskey attribute proposes a keyboard shortcut for an element. You give it one or more single characters, and the browser binds the first one it can to a modifier combination — commonly Alt (Windows) or Control+Option (macOS), sometimes with Shift.
In practice accesskey is used sparingly: the trigger combination differs across browsers and platforms, the shortcuts are not discoverable, and they frequently clash with the browser's own shortcuts or those of screen readers. If you do use it, tell users the shortcut exists and choose keys that avoid conflicts.
Syntax
<button accesskey="s">Save</button>
Values
| Value |
|---|
| One or more space-separated single characters. |
Example
<button accesskey="s" style="padding:6px 12px;">Save <small>(accesskey: s)</small></button>
Best practices
- Use
accesskeysparingly and only for genuinely common actions. - Avoid characters that clash with browser or screen-reader shortcuts.
- Tell users the shortcut exists — accesskeys are not discoverable on their own.
- Never rely on it as the only way to perform an action.
Accessibility
Although accesskey sounds like an accessibility feature, it often harms it: a chosen key can override a shortcut a screen-reader or keyboard user depends on, and there is no built-in way for users to learn which keys are bound. If you use it, surface the shortcut visibly (for example in a tooltip or menu) and pick keys carefully.