Interface Core A1 · Official standard Platform: Web

Keyboard Trap

A keyboard trap happens when focus enters a part of the page but cannot leave with the keyboard.

See how it works
You might call it focus trap failuretrapped focus

See how it works

Original worked exampleKeyboard Trap

Another example

A traveler opens a date picker. They can move between dates, press Escape to close it, or press Tab after choosing. A broken calendar catches every Tab press and gives no way out.

Main parts

  1. 01Entry path
  2. 02Internal operation
  3. 03Documented exit

Use it when

Test every complex widget, overlay, embedded editor, and third-party frame with only a keyboard. Make sure people can enter and leave.

Do not use it when

A modal focus loop is not a trap when Escape and a visible close button always let people leave.

Name used in code

keyboard-only test: enter, operate, Escape or Tab out

Before you ship

Before release, check the page structure, keyboard access, visible focus, contrast, and zoom. Also check loading, empty, error, success, cancel, and reduced-motion states.

Request you can copy

Outcome: Use Keyboard Trap to solve this user need without losing the current context. User context: A traveler opens a date picker. They can move between dates, press Escape to close it, or press Tab after choosing. A broken calendar catches every Tab press and gives no way out. Recommended pattern: Keyboard Trap. Why it fits: Test every complex widget, overlay, embedded editor, and third-party frame with only a keyboard. Make sure people can enter and leave. Do not use it when: A modal focus loop is not a trap when Escape and a visible close button always let people leave. Product requirements: Define the default, loading, empty, error, success, and recovery states. Keep user input. Give clear feedback after every action. Accessibility and resilience: Use semantic HTML, full keyboard access, and visible focus. Make the layout work when zoomed and support reduced motion. Follow the project’s current rules. Do not add a new UI library unless the project already uses it. Acceptance criteria: The main task works with keyboard only and at 320px width. Focus and status changes are announced. Check loading, failure, retry, cancel, and reduced-motion paths. Evidence and limits (evidence boundary): The standard covers only the listed scope. It does not choose the visual style, product decision, or Vibulary example. Unknowns to confirm: Product wording, data source, analytics events, supported devices and languages, and platform limits.

Check this request

Review the current use of Keyboard Trap. Definition: A keyboard trap happens when focus enters a part of the page but cannot leave with the keyboard. Release checks: Before release, check the page structure, keyboard access, visible focus, contrast, and zoom. Also check loading, empty, error, success, cancel, and reduced-motion states. Before changing code, report the evidence you found, gaps, severity, and the smallest safe fix.

A1
How official is this term?

Official standard

A named standard sets the rules described on this page.

The standard covers only the listed scope. It does not choose the visual style, product decision, or Vibulary example.

Scope
WCAG 2.2 Success Criterion 2.1.2
Document status
recommendation
Checked on
2026-07-30

Evidence sources & scope

Authority source + Term reference · W3C · recommendation Web Content Accessibility Guidelines (WCAG) 2.2 — Success Criterion 2.1.2 No Keyboard Trap Success Criterion 2.1.2 No Keyboard Trap Scope: Web accessibility conformance; direct scope: Success Criterion 2.1.2 No Keyboard Trap Role here: Direct term reference Source covers: accessibility, usage guidance, avoidance guidance Authority source · W3C · recommendation Web Content Accessibility Guidelines (WCAG) 2.2 Scope: Web accessibility conformance Role here: Authority within stated scope Source covers: accessibility, usage guidance, avoidance guidance Authority source · W3C WAI · stable Understanding Success Criterion 2.1.2: No Keyboard Trap Scope: Explanation and techniques for avoiding keyboard traps Role here: Authority within stated scope Source covers: accessibility, usage guidance, avoidance guidance

Copy it yourself

The browser could not copy this. Select the request below and copy it yourself.