WCAG 2.1.2 No Keyboard Trap
Success Criterion 2.1.2 requires that if keyboard focus can be moved to a component using a keyboard interface, focus can also be moved away from that component using only a keyboard — and if it requires more than simple arrow/tab keys to exit, the user must be told how. It's a Level A criterion under Guideline 2.1 (Keyboard Accessible), closely related to 2.1.1 Keyboard.
Why this is a separate criterion from Keyboard itself
A component could technically satisfy "operable by keyboard" (2.1.1) — a modal that opens via Tab — while still failing this criterion if there's no keyboard-accessible way to close it and return focus to the rest of the page. Being able to enter a component and being able to leave it are genuinely distinct requirements, which is exactly why WCAG separates them.
The classic example
A modal dialog or embedded widget (an old-style Flash object, some custom-built rich text editors, certain third-party embeds) that captures keyboard focus and never releases it — a keyboard user tabs in, and there's no Escape key handler, no accessible close button, and Tab just cycles endlessly within the trapped component with no way out. The user is stuck.
The narrow exception
If exiting genuinely requires more than standard arrow keys, Tab, or other standard exit methods, that's permitted only if the user is informed how — for example, a code-editor widget that intentionally captures Tab for indentation would need to tell the user "press Escape then Tab to move focus out" rather than silently trapping them with no guidance at all.
How to check for this
Tab into every interactive component on a page and confirm you can Tab (or Escape, then Tab) back out to the rest of the page. This is a fast, mechanical manual test — unlike many WCAG criteria, a genuine keyboard trap is usually obvious the moment you try it, since you'll find yourself unable to leave.
Common questions
- What is WCAG 2.1.2?
- A Level A criterion: if you can move focus into a component with the keyboard, you must be able to move it out again with standard keys, never getting trapped.
- What is a common keyboard trap?
- A modal dialog or embedded widget (like a media player or third-party plugin) that captures Tab and won't let focus escape back to the page.
- How do I fix a keyboard trap?
- Ensure Tab, Shift+Tab, and Escape move focus out of every component; for modals, implement a proper focus trap that still allows closing and returning focus.
Related articles
Want to see how your own site scores?
Run a free accessibility scan