Keyboard navigation

Keyboard navigation is moving through a web page and operating everything on it with the keyboard alone. Tab and Shift+Tab move focus between links, buttons and fields, Enter and Space activate them, arrow keys move inside menus, tabs and other widgets, and Escape closes what was opened. Keyboard accessibility is the property of a page that allows it.

The longer version

People who cannot use a mouse depend on it, and so do most screen reader users, because a screen reader is driven from the keyboard. Other input devices, such as switches, reach a page through the same route, which WCAG calls the keyboard interface and defines as the interface used by software to obtain keystroke input. The conventions come from the W3C's ARIA Authoring Practices Guide. Tab moves between components, and inside a composite widget such as a menu, a tab list or a grid, the arrow keys move between its parts, because, in the guide's words, the tab sequence should include only one focusable element of a composite UI component. A developer builds that with a roving tabindex, where only the active item can take focus from Tab, or with aria-activedescendant, where the container keeps focus and points at the active child.

WCAG 2.2 sets the requirements. At Level A: 2.1.1 Keyboard, all functionality operable through a keyboard interface; 2.1.2 No Keyboard Trap, focus can always be moved away again; 2.1.4 Character Key Shortcuts, single-character shortcuts can be turned off, remapped or limited to when the component has focus; 2.4.1 Bypass Blocks, a way such as a skip link past repeated content; 2.4.3 Focus Order, an order that preserves meaning and operation; and 3.2.1 On Focus, receiving focus does not change the context. At Level AA: 2.4.7 Focus Visible and 2.4.11 Focus Not Obscured (Minimum), which asks that the focused component is not entirely hidden by content the author placed over it. Level AAA adds 2.1.3 Keyboard (No Exception), 2.4.12 Focus Not Obscured (Enhanced) and 2.4.13 Focus Appearance. Several pages that rank for this term number the focus criteria wrongly, and the Recommendation is the place to check.

Testing it takes no tool. Put the mouse aside, click into the address bar and press Tab until you have been through the whole page and every flow on it, asking at each stop whether you can see where focus is, whether the order makes sense, whether the control works with Enter, Space or the arrows, and whether you can leave it. On a Mac, Safari skips links when Tab is pressed until Press Tab to highlight each item on a webpage is ticked in Safari Settings, under Advanced, which is a common reason a tester believes a page is broken when it is not. The usual failures are a clickable div that takes no focus, an outline removed by a stylesheet with nothing in its place, a date picker or modal that can be entered and never left, a sticky header covering the focused field, and focus dropped to the top of the page when a dialog closes.

A keyboard finding is reproduced only if it says where focus was, which key was pressed and what happened, in which browser, with the criterion it fails. A screen recording with the focus ring visible shows the order better than any sentence, and the accessibility checklist in the Notarus templates gives each keyboard check its criterion so the finding has something to cite.

Common questions

How do you use keyboard navigation on a website?

Press Tab to move forward through links, buttons and form fields, and Shift+Tab to move back. Press Enter to follow a link or press a button, Space to press a button or tick a checkbox, the arrow keys to move within menus, radio groups and tabs, and Escape to close a menu or dialog. On a Mac, Safari needs a setting before Tab reaches links.

What is keyboard accessibility?

Keyboard accessibility means every function of a page can be reached and operated with a keyboard alone, focus is always visible, the order makes sense and nothing traps the user. WCAG 2.2 makes 2.1.1 Keyboard and 2.1.2 No Keyboard Trap Level A requirements and 2.4.7 Focus Visible a Level AA one.

How do you scroll a website with the keyboard?

Space scrolls down one screen and Shift+Space scrolls up, Page Down and Page Up do the same, the arrow keys scroll in small steps and Home and End jump to the top and bottom. These work when focus is on the page itself and not inside a text field, where the same keys move the cursor instead.

What is a keyboard trap?

A keyboard trap is a component that focus can enter by keyboard and cannot leave by keyboard, such as a modal, a date picker or an embedded player that swallows Tab and Escape. WCAG 2.2 criterion 2.1.2 No Keyboard Trap, Level A, forbids it, and the user has to reach for a mouse or reload the page.

Why does Tab skip links in Safari on a Mac?

Safari does not stop on every link and button when Tab is pressed until a setting is changed. Ticking Press Tab to highlight each item on a webpage, in Safari Settings under Advanced, makes Tab stop on links and buttons too. Testers should switch it on before a keyboard pass, or links will look unreachable when they are not.

Can automated tools test keyboard navigation?

Scanners can flag some symptoms, such as an element with a click handler and no keyboard role, or a positive tabindex. Whether focus is visible, whether the order makes sense and whether a widget can be left are judged by a person pressing the keys, so a keyboard pass by hand stays part of every accessibility check.

Bug reports that arrive ready to triage.

Collect replay, console, network and browser context with the Free plan.

<script src="…/widget.js" data-key="pb_pub_…">