Keyboard Trap
A keyboard trap happens when focus enters a part of the page but cannot leave with the keyboard.
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
- 01Entry path
- 02Internal operation
- 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.
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.