WCAG 2.2 - All Success Criteria

Accessibility Checkpoints

Description

If keyboard focus can be moved to a component using a keyboard interface, then focus must be able to be moved away from that component using only a keyboard. If moving focus away requires more than standard navigation keys, users must be informed of the method. This ensures that keyboard users cannot become stranded inside a widget or page region with no way to escape.

How To Test

  1. Navigate to the page using only the keyboard (Tab and Shift+Tab).
  2. Tab into each interactive widget, embedded iframe, media player, and modal dialog.
  3. After entering each component, attempt to exit by pressing Tab, Shift+Tab, and Escape.
  4. Verify that focus moves away from the component without requiring mouse interaction.
  5. If a component uses a non-standard exit key, check that this is communicated to the user through visible instructions or an accessible announcement.
  6. For modal dialogs, confirm that Escape closes the dialog and returns focus to the element that opened it.

Testing Tools

Demo

Demo 1: Modal without escape mechanism

This code demonstrates a keyboard trap pattern. A live implementation would be unsafe for keyboard users — do not interact with it. The modal below only has a "Yes" button and no Escape handler:

Code
Code
Demo 2: Positive tabindex focus trap

This code uses positive tabindex values to force a specific focus order. When tabbing, focus skips to these elements and can become difficult to predict. Do not implement this pattern:

Code
Code
Demo 3: Rich text editor keyboard trap

This code demonstrates a text editor that traps Tab key for indentation. Users cannot reach the submit button using only the keyboard:

Code
Code

WCAG Techniques

  • Failures: F55 (Using script to make a control unrecoverable when focus is moved away), F85 (Using nested interactive form controls)
  • Success Techniques: H4 (Creating a logical tab order through links, form controls, and objects), G21 (Ensuring that users are not trapped in content), ARIA6 (Using aria-label to provide labels for objects), ARIA11 (Using ARIA landmarks to identify regions of a page)

Fail Explanation

A keyboard trap occurs when a user tabs into an element - such as an embedded media player, a third-party widget, or a custom dialog - and cannot move focus out using Tab, Shift+Tab, Escape, or any other standard key. For keyboard-only users, including many screen reader users, a trap makes the rest of the page permanently inaccessible during that session. Even a single trapped component is a critical blocker because it forces the user to refresh the page and lose their context.

Pass Explanation

A passing implementation ensures that pressing Tab, Shift+Tab, or Escape always allows focus to leave any component and continue navigating the page. When a modal dialog is open, focus may be intentionally constrained within the dialog, but a clearly labeled close mechanism (such as an Escape key handler and a visible Close button) must still allow the user to dismiss the dialog and return focus to the triggering element.

Notes

An intentional focus lock inside a modal dialog is acceptable - and often desirable - as long as the dialog itself is dismissible via keyboard. The failure condition is a component from which there is no keyboard escape at all, not one that constrains focus to a logical region while still providing an exit.

Techniques

WCAG techniques used in this demo: G21

Suggested Solutions & References

Curated from 9 real-world audit findings and official WCAG guidance.