Skip to main content
Vially Logo

WCAG 2.1 Criteria Documentation

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

ScenarioFix
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 GroupWith Keyboard TrapWith Free Navigation
Motor DisabilitiesUsers cannot interact beyond the trapped areaSmooth navigation through all interactive elements
Screen Reader UsersMay be stuck in a single focus area, missing contentStandard tab navigation provides full access
Low Vision / Keyboard UsersExperience navigation dead endsCan predictably tab forward and backward through UI
General UsersFrustration and confusion with navigation flowConsistent and intuitive keyboard experience

Supporting Documentation

Remediation Strategies

  • 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.
  • Elements must follow DOM order unless overridden with accessible scripts.
  • Avoid JavaScript that disrupts tab behaviour unless explicitly intended and documented.
  • Use Tab, Shift + Tab, Enter, and ESC key to confirm users can navigate all UI elements.
  • If using iframes, chat widgets, or embedded tools, test for keyboard compliance or provide accessible alternatives.
  • For example: “Press ESC key to close this dialog.”
  • 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.