2.1.2: No Keyboard Trap

What it means

Keyboard focus must not get trapped in a component unless the user can escape with standard keys. Modal dialogs should loop focus inside until closed, but users must always be able to exit.

Trapped focus leaves people stuck with no way forward.

How to fix it

  • Allow Esc to close modals, menus, and overlays that capture focus.
  • Test Tab and Shift+Tab through widgets to ensure focus can leave when appropriate.
  • If focus is intentionally trapped (modal), provide a clear Close control.
  • Fix third-party embeds that capture keyboard input without an exit path.

Quick examples

  • Good: A login modal loops Tab inside and closes with Esc, returning focus to the trigger.
  • Bad: Focus enters a chat widget and Tab never reaches the rest of the page.
  • Good: A date picker closes and restores focus when the user presses Esc.
  • Bad: An auto-open promo traps keyboard users with no dismiss button.

W3C Understanding 2.1.2: No Keyboard Trap — full official details