KBD-001 Let the keyboard do everything the pointer can, and show where focus is
- Level
- Rule
- Verdict
- Requirement
- Area
- Keyboard
- Status
- decided, version 1.0.4
Rule
Everything a person can do with a pointer can also be done with the keyboard alone, unless the task depends on the path of the movement; and whenever an element has keyboard focus, a visible indicator marks it for as long as it has focus.
Examples
Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.
Do: Show more trips is a real button
Don't: Show more trips is a div that only takes clicks
Why
Many people never touch a mouse or a touch screen. Some cannot see a pointer, some cannot hold one steady, and some move faster with keys. For them, a task that needs a pointer is a task they cannot finish, and a page that hides focus leaves them guessing where the next key press will land. WCAG 2.2, 2.1.1 Keyboard requires that all functionality works from a keyboard, either through the same control or through a comparable keyboard route that reaches the same result, and 2.4.7 Focus Visible requires that keyboard focus can be seen. Neither sets a size or a shape for the indicator. When we style the indicator ourselves, 1.4.11 Non-text Contrast also applies: it shows a state, so the part people need to see in order to find focus needs at least 3:1 against the colours next to it. Those are the colours it actually touches, so where you draw the ring decides what it is measured against. An indicator left exactly as the browser draws it is outside that figure but must still be visible. 2.4.13 Focus Appearance sets further thresholds, but it is Level AAA, so it is a further step you may take, not a requirement of this rule.
Do
- Build actions from real
<button>,<a href>and form elements. They take focus and respond to keys without extra code. In the shadcn adapter,Button,Checkbox,RadioGroupItem,Switchand the field controls already do this. Their role in code is ACT-009. - Give a sortable list My favourites a keyboard route next to the drag handle: a menu on each row with Move up and Move down, or arrow keys while the row is picked up. Keep a click or tap way that needs no dragging too, as ACT-007a requires; what a screen reader hears during the move is ACT-007b.
- Let a price slider Price, £0–£5,000 move with the arrow keys, and let Home and End jump to its ends.
- When a row in Upcoming bookings shows Change and Cancel booking on hover, show them on keyboard focus as well. In a table row, TBL-003 covers this.
- Offer a keyboard shortcut such as Alt+Shift+N for New note, matched on
e.codeso Option on a Mac does not change the key, as an extra, beside a button that does the same thing. Which keys to choose and how people find and change them is KBD-003, KBD-003a and KBD-003b. - Keep the indicator on for as long as the element has focus. Showing it only for keyboard focus, as
:focus-visibledoes, is fine. - Keep the visible part of an indicator we style ourselves at 3:1 or more against the colours next to it, in both themes. We measure in both themes, as VIS-001 explains. Our
focusRingdraws a 2px ring outside the control with a 2px gap in the page colour, and our contrast test checks the ring against the page, card, muted and accent surfaces in both themes. - Make the indicator survive forced-colours mode (Windows high contrast). That mode drops box shadows, so a shadow ring alone disappears. Our
focusRingkeepsoutline-noneon the base state and addsfocus-visible:outline-hidden, a transparent outline that forced-colours mode draws in a system colour, so an outline appears there on keyboard focus. This is our own technical point. - Give every focusable thing an indicator: links, switches, radio buttons, a scrollable Terms box and a card that acts as one big link.
Don't
- Put a click handler on a
<div>that looks like a button, such as Show more trips, and give it no focus and no key handling. - Let a file upload Upload receipt work only by dropping files on a drop zone, with no button that opens the file picker. It fails ACT-007a as well.
- Set
outline: noneon all controls and add nothing in its place, so Tab moves through Search tickets without any visible sign. - Show focus on Add passenger only by turning its background a shade lighter. It is easy to miss and may rely on colour alone; use a ring or an outline.
- Let the ring fade out a second after a control gets focus.
- Move focus away by script as soon as an element receives it.
- Make a key held down for two seconds, or a fast double press, the only way to confirm Confirm payment.
- Treat a mode that steers the mouse pointer with the arrow keys as keyboard support.
Exceptions
- Path-based tasks. When the result is the path itself, such as tracing a running route by hand on a map in Draw your route, that tracing is exempt. The controls around it, such as Undo, Clear and Save route, are not, and a way to enter the route stop by stop is still welcome.
- Disabled controls. A control that is off need not take focus; ACT-005 relies on this.
- Neighbouring rules. Getting out of a dialog by keyboard is in DLG-001, focus into, inside and out of a modal dialog is in DLG-006 and DLG-007, the order focus moves in is in LAY-002, and focus hidden by sticky bars or other layers is in KBD-002. The way without dragging is ACT-007a, sortable table headers TBL-002 and row actions TBL-003. A control's role is ACT-009, its hover and pressed looks VIS-008, and Enter in a form FRM-015. This rule does not repeat them.
Verdict
Requirement. Only the judges decide; the expert witnesses are shown but do not vote. How verdicts work
| Source | Role | Stance | Page |
|---|---|---|---|
| WCAG 2.2 | Law | Requires | 2.1.1 Keyboard |
| WCAG 2.2 | Law | Requires | 2.4.7 Focus Visible |
| WCAG 2.2 | Law | Supports | 1.4.11 Non-text Contrast |
| Material Design | Judge | Supports | Accessibility designing: flow States: applying states Buttons: accessibility |
| Apple Human Interface Guidelines | Judge | Supports | Accessibility Keyboards Focus and selection (ipados, macos, tvos, visionos; not ios or watchos; no web guidance) |
| Carbon Design System | Judge | Supports | Accessibility: keyboard Accessibility: overview Button: accessibility |
| GOV.UK Design System | Expert witness | Supports | Understanding focus state styles |
| Nielsen Norman Group | Expert witness | Supports | Keyboard-Only Navigation for Improved Accessibility, by Marieke McCloskey |
Each stance links to the page it rests on, read on the date in the source register. This page never repeats what a source says; read the source itself.
History
- Version 1.0.4, : Points to KBD-003, KBD-003a, KBD-003b, ACT-009, VIS-008 and FRM-015. The shortcut example is now Alt+Shift+N, since browsers keep Ctrl+Shift+N.
- Version 1.0.3, : Points to ACT-007a, ACT-007b, TBL-002 and TBL-003, and to VIS-001 for measuring in both themes.
- Version 1.0.2, : Neighbouring rules now name DLG-006 and DLG-007.
- Version 1.0.1, : Examples in English.
- Version 1.0.0, : First version.
Last checked against the other rules for conflicts on .
More in Keyboard: 5 rules and 0 guidelines · All rules
Justified is an independent project. It is not affiliated with, sponsored or endorsed by the organisations whose guidance it cites. Read the full statement.
Apple is a trademark of Apple Inc., registered in the U.S. and other countries and regions.