HTML: the accesskey attribute
The accesskey attribute assigns a keyboard shortcut to an interactive element such as a link or button.
What you will learn
- How to assign a shortcut with
accesskey - Why shortcut combinations differ between browsers and operating systems
- How to use this feature carefully without making a page harder to access
Minimal example
<a href="/help.html" accesskey="h">Help</a>
<button type="button" accesskey="s">Save</button>
The value identifies the key associated with the element. The browser combines it with a modifier key, but the exact combination depends on the browser, operating system, and user settings.
Why caution is important
- A shortcut can conflict with a browser, operating system, or assistive technology command.
- Users may not know that a shortcut exists unless the page documents it.
- Different users may expect the same key to perform different actions.
Good practice
- Use shortcuts only for actions where they provide clear value.
- Test with the browsers and assistive technologies your audience uses.
- Tell users which shortcuts are available and let them customize or disable them when possible.
- Prefer a logical focus order and clear visible controls before adding shortcuts.