Barrierepruefung.de Web Accessibility Checker

WCAG 2.1.2 No Keyboard Trap: explained simply

If keyboard focus can move into part of a page, it must be able to move out again using the keyboard alone. If that takes more than Tab, arrow keys or another standard exit method such as Escape, the page must tell users how. This applies to all content on the page, embedded content included.

Last reviewed: Sources

What does the criterion require?

People who use a site with the keyboard alone move from element to element with the Tab key. A keyboard trap is a part of the page they can get into that way but not out of: focus cycles inside it or sticks to one element, and the rest of the page is out of reach. This affects everyone who relies on a keyboard or keyboard interface, including people who are blind and people with physical disabilities.

So the criterion requires: if keyboard focus can be moved to a component of the page using a keyboard interface, it can be moved away again using only a keyboard interface. If that takes more than the unmodified Tab or arrow keys or another standard exit method, users must be told how to get out.

The criterion does not define a "standard exit method". According to the W3C it depends on the hardware, browser and operating system. With a physical keyboard, the Escape key is a common one in most environments.

The W3C notes that traps often appear where a page combines several formats rendered by plug-ins or embedded applications, or where custom components were built without keyboard users in mind.

Deliberately restricted focus is allowed

Sometimes focus is meant to stay inside a region. The W3C's example is a modal dialog, a window that blocks the rest of the page until it is closed. While it is open, tabbing from its last control goes back to its first. That is not a trap as long as users know how to leave, in the example through "Cancel", "OK" or the Escape key.

A rich text editor may also claim Tab for itself, for instance to indent a line. In the W3C's example an instruction appears when the editing area gets focus, naming the key combination that moves focus back to the toolbar. An embedded puzzle may likewise handle keystrokes itself if instructions before and inside it name the key that exits it.

Applies to the whole page

This is one of four criteria that apply to all content on a page, including content that is not otherwise relied upon to meet conformance. The reason: a single trap can interfere with a user's ability to use the whole page. WCAG sets this out in Conformance Requirement 5 (Non-Interference). The other three are 1.4.2 Audio Control, 2.2.2 Pause, Stop, Hide and 2.3.1 Three Flashes or Below Threshold.

Common failures

  • Embedded content holds on to focus. A user tabs into content rendered by a plug-in and cannot return to the rest of the page with the keyboard. To regain control they have to restart the browser, and everything after that content stays out of reach (F10).
  • No way out of a sub-region. A region handles every keystroke itself and hands focus back neither at the end of its tab sequence nor through a key of its own. As solutions the W3C names these two exits or a command that the technology itself provides (G21). With none of them, and no other standard exit method either, the region is a trap.
  • An exit nobody is told about. The region can only be left with a special key combination, but nothing says which. That already misses the wording of the criterion. G21 places the instructions inside the region; where the technology brings its own command for leaving, they come before the region.

Checked automatically and checked by you

What the automated check detects

Coverage: extensive

The automated check covers most of this criterion, but not every case.

The case where focus cannot be released at all is found. Whether a deliberately bound focus — a modal dialog, a consent banner — is bound correctly is presented for review.

Rules

What you check yourself

You answer this question in the manual checks of your scan.

Can every area — dialog, menu, embedded content — be left again with the keyboard?

  1. Move with the Tab key to embedded content such as video players, maps, third-party forms and chat windows and check whether you can leave each of them again with the keyboard. The automatic check does not look inside embedded content; it reports focus that cannot be released at all only for the page itself.
  2. Open every dialog, every menu and every consent banner and leave it with the keyboard, with Esc, a close button or Tab. Afterwards focus must be back on the page. An area that deliberately binds focus, such as a modal dialog, must offer such a way out; whether it does is something the automatic check can only present for review.
  3. If leaving takes more than Tab, arrow keys or other customary ways, the page must tell the user how.

Classification

Level
A
Introduced in
WCAG 2.0
W3C explanation
Understanding 2.1.2