References

Beginner-friendly references for web development, with live, editable examples.

The HTML accesskey attribute

Global attribute Works on every element All modern browsers Updated
Quick answer

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

Live example
<button accesskey="s" style="padding:6px 12px;">Save <small>(accesskey: s)</small></button>

Best practices

  • Use accesskey sparingly 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.

Frequently asked questions

What is the accesskey attribute?
It suggests a keyboard shortcut that focuses or activates an element.
How do I trigger an accesskey?
With a browser-specific modifier plus the key — often Alt on Windows or Control+Option on macOS, sometimes with Shift.
Why is accesskey rarely used?
The trigger varies by browser and OS, the shortcuts are not discoverable, and they often conflict with browser or assistive-technology shortcuts.
Is accesskey good for accessibility?
It can backfire — its shortcuts may override ones screen-reader users rely on. Use it cautiously and make it discoverable.