A modal dialog that opens and never lets the keyboard out is a trap: the user can see the page behind it but cannot reach it. WCAG forbids keyboard traps and requires focus to move sensibly in a dialog. This check opens the dialog by keyboard and tests the way out.
Why this needs its own check
WCAG 2.1 success criterion 2.1.2 No Keyboard Trap, Level A, requires that if keyboard focus can be moved to a component, it can be moved away using only the keyboard, unless a standard way out is needed, such as Escape to close a dialog. The WCAG 2.2 checklist carries the same rule.
What you need before you start
- A page with a modal dialog, such as a login or image viewer
- A keyboard
- A note of the dialog’s controls
Step 1 – Open the dialog by keyboard
Tab to the button that opens the dialog and press Enter. If the dialog opens but focus stays on the page behind it, mark that as a failure: focus must move into the dialog.
Step 2 – Tab around inside the dialog
Press Tab repeatedly. Focus should cycle through the dialog’s controls and stay inside while it is open. If focus escapes to the page behind, or jumps to the browser chrome, mark it as a failure.
Step 3 – Close the dialog with Escape
Press Escape and confirm the dialog closes and focus returns to the button that opened it. If Escape does nothing and there is no keyboard way to close it, mark it as a failure.
Worked example
Practice check: a fictional Alder and Ash Architects image viewer
The example below is fictional. Alder and Ash Architects is an invented business used only as a practice case. No real customer, page, or product is shown. Treat it as a practice case, not as evidence about any real business.
| Part | What it should be | As shown | Result |
|---|---|---|---|
| Focus moves into dialog | Focus enters the dialog | Focus enters the dialog | Pass |
| Focus stays inside dialog | Focus cycles inside only | Focus escapes to the page behind | Fail – focus escapes |
| Escape closes dialog | Escape closes and returns focus | Escape closes and returns focus | Pass |
| Close button reachable | Close button reachable by Tab | Close button cannot be reached | Fail – close button unreachable |
Only 2 of the 4 checks pass: focus entering the dialog and Escape closing it. The two failures are focus escaping to the page behind and the unreachable close button.
What to do when something is wrong
Trap focus inside the dialog while it is open, make the close button a real button in the tab order, and return focus to the trigger when the dialog closes. Re-test the whole sequence by keyboard.
Expected result. We checked the WCAG 2.2 checklist listed in Sources. We did not test a live Alder and Ash Architects dialog. UNTESTED: no keyboard pass was run on a real dialog; the practice table shows the expected result pattern for a dialog with two focus faults.
Limits
- This check covers keyboard traps in dialogs only. It does not cover whether the dialog content is announced to screen readers, or whether the dialog works by touch.
Sources
- WCAG 2.2 Checklist: All 55 Level A and AA Criteria (checked 2026-11-29)
