👀 Live Preview
Three buttons with letter access keys (try Alt + H, A, or C on Windows):

The accesskey attribute provides a way to define keyboard shortcuts for accessing specific elements on a web page. By assigning a key to an element, users can quickly navigate to it, improving accessibility and user experience.
Focus elements quickly.
Works on many elements.
One letter or number.
Alt or Ctrl+Option.
JavaScript DOM property.
Avoid shortcut conflicts.
accesskeyThe primary purpose of the accesskey attribute is to enhance the accessibility of a web page by allowing users to navigate to important elements using keyboard shortcuts. This is particularly beneficial for users with mobility issues who may find it challenging to use a mouse for navigation.
Users do not press the accesskey alone. They combine it with a browser-specific modifier—typically Alt on Windows/Linux or Ctrl + Option on macOS.
Add accesskey to any focusable or activatable element with a single character value:
<button accesskey="h">Home</button>accessKey.The accesskey attribute accepts single-character values, typically a letter or a number. These values are used as the access key that, when combined with a browser-specific modifier key, triggers the associated element:
accesskey="h" — Letter keys for navigation (Home, Help, etc.).accesskey="1" — Number keys for ordered shortcuts.accesskey="s" — Mnemonic keys matching the first letter of an action (Save, Search).<button accesskey="h">Home</button>
<a href="/search" accesskey="s">Search</a>
<input type="submit" value="Go" accesskey="g">| Platform | Modifier + accesskey | Example |
|---|---|---|
| Windows / Linux | Alt + key | Alt + H |
| macOS | Ctrl + Option + key | Ctrl + Option + H |
| HTML attribute | accesskey="h" | On button or link |
| JavaScript | el.accessKey = "p" | camelCase property |
| Value type | Single character | Letter or digit |
| Attribute type | Global | Most HTML elements |
accesskey is a global attribute and can be used on most HTML elements, especially those that receive focus or can be activated:
| Element | Common use | Notes |
|---|---|---|
<button> | Action shortcuts | Focuses and may activate |
<a> | Navigation links | Follows the link on activation |
<input> | Form controls | Focuses the field |
<label> | Associated control focus | Activates linked input |
Navigation buttons, dynamic JavaScript shortcuts, and link access keys.
Three buttons with letter access keys (try Alt + H, A, or C on Windows):
Let’s explore a simple example of how to use the accesskey attribute in an HTML document:
<button accesskey="h">Home</button>
<button accesskey="a">About</button>
<button accesskey="c">Contact</button>In this example, each button is assigned a different access key: h for Home, a for About, and c for Contact. Users activate these buttons by pressing the designated access key with the browser modifier.
You can dynamically set the accesskey attribute using JavaScript based on user preferences or dynamic content changes:
<script>
document.getElementById("dynamicElement").accessKey = "p";
</script>In this script, the accesskey attribute is dynamically set to p for an element with the id dynamicElement. Note the camelCase accessKey property in JavaScript.
Assign number access keys to navigation links for quick keyboard access:
<a href="#home" accesskey="1">Home</a>
<a href="#docs" accesskey="2">Docs</a>
<a href="#help" accesskey="3">Help</a>Number keys provide ordered shortcuts. Document them visibly so users know they exist—access keys are not discoverable by default.
Set a single character on a button, link, or input.
Browser interprets the shortcut using platform conventions.
The target element is focused or activated, depending on its type.
Power users and assistive-tech users reach key controls without a mouse.
The accesskey attribute is supported in all modern browsers. Modifier key combinations and focus behavior may differ slightly by platform.
All major browsers honor accesskey on supported elements.
Bottom line: Use accesskey when shortcuts add clear value; test modifier behavior on each target platform.
The accesskey attribute is a powerful tool for improving the accessibility and usability of web pages. By incorporating keyboard shortcuts thoughtfully, you can make navigation more efficient for users, particularly those with disabilities or those who prefer using the keyboard over the mouse.
Use access keys sparingly, document them clearly, and always test behavior across browsers to ensure a consistent experience.
accesskeyBookmark these before adding keyboard shortcuts to your UI.
Modifier + key.
BasicsMany elements.
ScopeOne letter/digit.
ValuesJavaScript property.
DynamicAvoid conflicts.
A11yelement.accessKey = "p" (camelCase, no hyphen).Practice the accesskey attribute with buttons, links, and dynamic JavaScript in the Try It editor.
5 people found this page helpful