---
title: "No Keyboard Trap"
url: "https://www.barrierefreihochzwei.de/en/wcag/2-1-2-no-keyboard-trap"
language: "en"
description: "WCAG 2.1.2 requires that keyboard users never get stuck in an element. Learn how to spot and avoid keyboard traps in dialogs, widgets and embedded content."
published: "2025-01-01T08:00:00+01:00"
updated: "2026-10-15T09:41:59+02:00"
---

# No Keyboard Trap

When there’s no way out.

- **Erfolgskriterium:** 2.1.2
- **Prinzip:** Operable
- **Konformitätsstufe:** Level A
- **Erklärung beim W3C:** [www.w3.org/WAI/WCAG22/Understanding/no-k...](https://www.w3.org/WAI/WCAG22/Understanding/no-keyboard-trap.html)

Success criterion 2.1.2

# 2.1.2 No Keyboard Trap

Level AOperable

When there’s no way out.

## 1. What is the goal of this criterion?

You may know the feeling from escape rooms – the thrill, but also the panic when you can’t find the way out. That’s exactly what happens to keyboard and screen reader users when they get “trapped” in an element on a website and can’t get out again.

The goal of Success Criterion 2.1.2 is to make sure nobody gets stuck in any part of your website. Everyone must be able to use the keyboard not only to get into every element but also to get out again – without resorting to the mouse.

## 2. What exactly does it require?

Put simply, it’s one rule: **if you can get in with the keyboard, you must be able to get out with the keyboard.**

If keyboard focus can be moved to an element, it must also be possible to move it away using only the keyboard. That means:

- **Standard navigation:** Tab, Shift+Tab or the arrow keys are usually all you need
- **Special components:** if leaving requires more than unmodified arrow or Tab keys or other standard methods, users must be told how – ideally before they enter the element
- **All areas of the page:** dialogs, widgets, embedded content such as video players or maps, forms – everything must be leavable

**Special feature:** 2.1.2 is one of the criteria subject to “non-interference”. It applies to all content on a page – even content that isn’t meant to be part of the accessible version. A single keyboard trap can make the whole page unusable.

**An important distinction:** a modal dialog that deliberately keeps focus inside the dialog is not a keyboard trap – as long as it can be closed with the keyboard, for example with Escape or a close button.

## 3. Why does it matter for accessibility?

Imagine navigating a website using only the keyboard and ending up in an embedded player. No matter what you press, you can’t get out. That’s not just frustrating – it makes the entire website unusable.

Keyboard traps create real barriers because they:

- **Stop blind and visually impaired people** from moving on with their screen reader
- **Block people with motor impairments** who can’t use a mouse
- **Slow down power users** who work efficiently with the keyboard
- **Let down everyone** whose mouse or touchpad isn’t available at the moment

And the insidious part: a single keyboard trap can make the entire website unusable – even if every other area is exemplary.

## 4. How to meet the criterion

The good news: keyboard traps are usually easy to avoid if you follow a few ground rules.

**Basics for all elements:**

- Test every interactive area: can you get in with Tab and back out with Tab or Shift+Tab?
- Use native HTML elements whenever possible – they usually come with the right behavior
- Don’t forget backward navigation: Shift+Tab must always work
- Don’t intercept keyboard events like Tab across the board, for example in editors or games – or document the way out

**For modal dialogs and popups:**

- Move focus into the dialog when it opens
- Offer Escape and a visible close button
- Keep focus inside the dialog (Tab wraps from the last to the first element) – this is allowed because the dialog can be closed with the keyboard
- Return focus to the triggering element after closing
- The native `<dialog>` element with `showModal()` takes some of this work off your hands

**For complex widgets and embedded content:**

- If a widget needs special keys to leave it, explain them visibly beforehand, e.g. “Press Esc to leave the editor.”
- Prefer standard ways out (Tab, Shift+Tab, Esc)
- Check embedded third-party content (video players, maps, chat widgets) – you’re responsible for it too

**The most important test:** put your mouse away and navigate your entire website using only the keyboard. If you get “stuck” anywhere, you’ve found a keyboard trap. For keyboard operation in general, see [Keyboard](https://www.barrierefreihochzwei.de/en/wcag/2-1-1-keyboard).

## 5. Why this criterion matters for businesses

Keyboard traps aren’t just an accessibility issue – they directly cost you customers and business opportunities.

### 1. Reach a wider audience

A part of your website that people can’t get out of is like a shop without an exit. You lose not only people with disabilities but also everyone who currently has to rely on the keyboard – for example because their mouse is broken.

### 2. Avoid legal risks

Keyboard traps violate a Level A criterion and make websites completely unusable for many people with disabilities. Blockers like these are quickly spotted in audits.

### 3. Improve the experience for everyone

Keyboard navigation isn’t only relevant for people with disabilities. Power users, developers and anyone who wants to work efficiently use the keyboard. Keyboard traps frustrate them needlessly too.

**Last but not least: legal requirements.** The European Accessibility Act (Directive (EU) 2019/882) has applied since 28 June 2025 to many consumer products and services, such as online shops; in Germany it is implemented by the Barrierefreiheitsstärkungsgesetz (BFSG). The technical benchmark is the harmonised standard EN 301 549, which references WCAG 2.1 Level AA for web content – and 2.1.2 is part of that. Public sector bodies are covered by the Web Accessibility Directive (EU) 2016/2102. This section is general information, not legal advice.

## 6. The success criterion in the W3C’s words

> **Success Criterion 2.1.2 No Keyboard Trap (Level A)**
> 
> If keyboard focus can be moved to a component of the page using a keyboard interface, then focus can be moved away from that component using only a keyboard interface, and, if it requires more than unmodified arrow or tab keys or other standard exit methods, the user is advised of the method for moving focus away.
> 
> **Note:** Since any content that does not meet this success criterion can interfere with a user's ability to use the whole page, all content on the web page (whether it is used to meet other success criteria or not) must meet this success criterion. See Conformance Requirement 5: Non-Interference.

In short: if keyboard focus can move into a component, it must be able to leave it using only the keyboard – and if special keys are needed, users must be told which ones.

**Official explanation from the W3C**

The W3C explains every success criterion in depth – with intent, examples and techniques.

[Understanding 2.1.2](https://www.w3.org/WAI/WCAG22/Understanding/no-keyboard-trap.html)

## More criteria from “Operable”

 [  2.1.1 Level A ### Keyboard

When every click can also be a keystroke.

 ](https://www.barrierefreihochzwei.de/en/wcag/2-1-1-keyboard) [  2.1.3 Level AAA ### Keyboard (No Exception)

When everything really has to work by keyboard.

 ](https://www.barrierefreihochzwei.de/en/wcag/2-1-3-keyboard-no-exception) [  2.1.4 Level A ### Character Key Shortcuts

When single keys become a problem.

 ](https://www.barrierefreihochzwei.de/en/wcag/2-1-4-character-key-shortcuts)
