Website Spec
← Accessibility
Required

Keyboard navigation

Every interactive element on the page must be reachable and operable with a keyboard alone, in a logical order, with no traps that hold focus.

What it is

Keyboard navigation is the ability to reach and operate every control on a page using only a keyboard — Tab and Shift+Tab to move, Enter and Space to activate, arrow keys inside composite widgets, Escape to dismiss. Many users never touch a mouse: people using switch devices, screen readers, voice control, or just a laptop trackpad they find painful.

Why it matters

If a control can be clicked but not focused, it does not exist for a large share of disabled users. WCAG 2.1.1 (Level A) requires all functionality to be operable from a keyboard. 2.1.2 (Level A) requires that focus is never trapped — the user must always be able to move on. 2.4.3 (Level A) requires the focus order to preserve meaning and operability.

How to implement

The cheapest way to get keyboard support right is to use the right HTML element:

<button type="button">Open menu</button>
<a href="/about">About</a>
<input type="checkbox" id="news"><label for="news">Subscribe</label>

Native <button>, <a href>, and form controls are focusable, operable, and announce their role for free. A <div onclick> gets none of that.

When you build a custom widget, you must add it back yourself:

Manage focus on view changes. When a dialog opens, move focus into it and trap it inside until it closes; then return focus to the element that opened it. Single-page navigations should move focus to the main heading of the new view.

Common mistakes

Verification

Sources