# Focus Trap

> The Tab key stays in one box, like a pop-up. It stays till you close it.

**Field:** Design  
**Category:** Accessibility  
**Also known as:** Keyboard Trap, Focus Lock

## Think of it like

It is like a fenced garden. Inside a pop-up you stay in the fence until you use the gate.

## Definition

A focus trap keeps the keys inside one area. Tab loops around it instead of leaving. Inside an open modal dialog that is good, because the page behind is blocked. Escape or a Close button must always let people out. A trap with no way out, anywhere on a page, is a serious bug that WCAG level A forbids.

## Example

In a cookie dialog, Tab cycles through Accept and Settings. Escape closes it and focus returns to the page.

## Why it matters

Done right, it stops people tabbing into a page they cannot see. Done wrong, it locks them in.

## Common mistake

Trapping focus with no exit. Always let Escape or a Close button release it.

## Three principles

- **Wanted in a modal.** Tab loops inside.
- **Always an exit.** Escape or Close.
- **Return focus.** Back to where it was.

## Related terms

- [Modal Dialog](https://learn.benibix.com/term/design/modal-dialog)
- [Tab Order](https://learn.benibix.com/term/design/tab-order)
- [Keyboard Navigation](https://learn.benibix.com/term/design/keyboard-navigation)

---

Source: https://learn.benibix.com/term/design/focus-trap
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
