Keyboard trap
Also called: Focus trap, No keyboard trap
A component that keyboard focus can move into but cannot move out of using the keyboard.
Definition
WCAG 2.1.2 No Keyboard Trap, Level A: if keyboard focus can be moved to a component of the page using a keyboard interface, then focus can be moved away from that component using only a keyboard interface. If that takes more than unmodified arrow or Tab keys or other standard exit methods, the user must be told how.
WCAG lists this among the criteria that apply to all content on the page, because a trap anywhere blocks the use of the whole page.
Why it matters
A keyboard user who gets stuck has no way out except reloading or closing the tab, and loses whatever they were doing. Typical traps are embedded media players and third-party widgets in iframes, rich text editors that capture Tab, and modals that keep focus inside but give no way to close them.
Keeping focus inside an open modal on purpose is fine and expected, as long as Escape or a close button lets the user leave.
How to test or meet it
Tab forward and backward through every page, including all embeds, widgets and dialogs. At each one, check that Tab, Shift+Tab or Escape moves focus out, or that the page explains the key to use.
Automated tools cannot detect keyboard traps; this needs a person with a keyboard. Third-party embeds deserve special attention because they change without your code changing.
WCAG criteria
- 2.1.2 No Keyboard Trap (Level A)
- 2.1.1 Keyboard (Level A)
Related terms
Sources
By the Perceivly team · Published . This explains a term; it is not legal advice.