2.1.2 No Keyboard Trap
If keyboard focus can be moved to a component using a keyboard interface, focus can be moved away from that component using only a keyboard interface, and if more than unmodified arrow or tab keys are required, the user is advised of the method.
Last reviewed: September 9, 2026
Understanding 2.1.2
Keyboard-only users, including many screen reader users, switch device users, and people with motor disabilities, must be able to move through every part of a page without a mouse. A component that captures focus and never releases it (a 'keyboard trap') can strand these users entirely, sometimes forcing a full page reload just to escape. This criterion exists to guarantee that entering any widget never becomes a dead end.
How to Meet It
Code Examples
document.getElementById('widget').addEventListener('keydown', function(e) {
if (e.key === 'Tab') {
e.preventDefault(); // Traps focus inside; Tab and Shift+Tab do nothing
}
});document.getElementById('widget').addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
closeWidget();
triggerButton.focus(); // Returns focus to a sensible location
}
// Tab and Shift+Tab are left untouched and move focus normally
});Frequently Asked Questions
Are modal dialogs that trap focus within themselves a violation of 2.1.2?
No. Intentionally containing focus inside an open modal is an accepted pattern (per the WAI-ARIA Authoring Practices) as long as Escape or another documented keyboard method closes the modal and returns focus to a logical place. 2.1.2 targets unintentional traps with no documented exit, not deliberate, escapable focus containment.
What if exiting a component legitimately requires more than Tab or arrow keys, like Ctrl+Page Down?
WCAG permits this only if the user is advised of the specific method needed, for example through visible on-screen instructions or the component's accessible name/description.
Related Success Criteria
Quick Facts
- Criterion2.1.2
- LevelA
- IntroducedWCAG 2.0
Automate Compliance
AccessiSight automatically scans and identifies 2.1.2 issues in your codebase.
Try Scanner Free