2.1.2 No Keyboard Trap – (Level A)
High-Level Description
This criterion ensures that keyboard-only users can navigate all interactive elements without getting stuck. It prevents situations where the screen reader focus enters a component, such as a modal or widget, but cannot move forward or backward via keyboard alone.
Detailed Description
When it Applies:
- Any content with custom interactive elements, such as modals, carousels, dropdowns, or embedded media players.
- Applies to all users relying on keyboard navigation, such as people with motor impairments, screen reader users, or those using keyboard overlays.
What’s Required:
- If a component receives keyboard focus, users must be able to exit it using standard navigation (Tab, Shift + Tab, ESC key, etc.).
- If a keyboard trap is necessary (e.g. for accessibility in a modal), users must be explicitly informed how to escape it.
Indicators of Non-Compliance:
- Focus enters a modal dialog, but there’s no way to return to the main content.
- Custom widgets trap focus inside them unless a mouse is used.
- Carousels, video players, or calendars consume focus but do not allow tabbing out.
Real World Scenarios
Scenario | Fix |
---|---|
Modal popup traps focus inside the dialog, with no tab escape. | Implement a keyboard handler that allows Tab to cycle within, and ESC to close. |
Custom dropdown menu traps focus with arrow keys but blocks Tab navigation. | Ensure Tab moves focus forward, and Shift + Tab backward as expected. |
Embedded iframe widget (e.g. chatbot or calendar) steals keyboard focus with no return path. | Ensure tabindex, focus delegation, and exit options are well-defined. |
Custom slider or stepper requires pressing arrow keys, but users cannot tab out. | Add a keyboard event listener to allow Tab navigation out of the component. |
Disability Impact
Disability Group | With Keyboard Trap | With Free Navigation |
---|---|---|
Motor Disabilities | Users cannot interact beyond the trapped area | Smooth navigation through all interactive elements |
Screen Reader Users | May be stuck in a single focus area, missing content | Standard tab navigation provides full access |
Low Vision / Keyboard Users | Experience navigation dead ends | Can predictably tab forward and backward through UI |
General Users | Frustration and confusion with navigation flow | Consistent and intuitive keyboard experience |
Supporting Documentation
- WCAG 2.1 Success Criterion 2.1.2 - No Keyboard Trap
- ARIA Authoring Practices – Modal Dialog and Focus Management
Remediation Strategies
1 - Follow ARIA Dialog Best Practices
- Use role="dialog" and ensure the first focusable element is focused on open.
- Trap focus within the modal only while it’s open, and release on close.
- Provide ESC key to exit or close.
2 - Ensure Logical Tab Flow
- Elements must follow DOM order unless overridden with accessible scripts.
- Avoid JavaScript that disrupts tab behaviour unless explicitly intended and documented.
3 - Test with Only the Keyboard
- Use Tab, Shift + Tab, Enter, and ESC key to confirm users can navigate all UI elements.
4 - Handle Third-Party Components Carefully
- If using iframes, chat widgets, or embedded tools, test for keyboard compliance or provide accessible alternatives.
5 - Inform Users if Focus is Intentionally Trapped
- For example: “Press ESC key to close this dialog.”
6 - QA Scripts and Events
- Ensure custom event listeners for key-down support expected interactions and do not prevent default behaviour unless necessary.
Vially & Vision Ireland
In testing, Vision Ireland users often encounter focus traps in modals, third-party widgets, and single-page applications. Even experienced users report abandoning forms or interfaces when they can’t navigate out of an element using the keyboard alone.
At Vially, we recommend thorough keyboard testing for all components. If you must trap focus, it must be intentional, user-informed, and easily escapable.