learn.web Back to the curriculum ↗

WCAG 2.2 / Inclusive Design / 03

Keyboard and focus systems

Design logical order, visible focus, unobscured targets, skip paths, and robust modal behavior.

Time
80 min
Mode
Learn → Make → Check
Path
Accessibility

By the end, you can…

Keyboard access is interaction architecture

Tab should move through interactive elements in a logical order. Arrow keys often move within composite widgets such as tabs or menus. Enter and Space activate according to native conventions. Avoid positive tabindex values, which create a second fragile reading order.

Visible focus is location information. It must remain distinguishable and not be hidden under sticky headers, cookie banners, or dialogs. WCAG 2.2 adds explicit focus-not-obscured requirements.

Move focus only for a reason

When a modal opens, focus moves inside; when it closes, focus returns to the trigger. After deleting an item, focus moves to a sensible neighbor or status. Routine content updates should not steal focus.

Test forward and backward, at zoom, and after every dynamic action. A keyboard trap is any state a person cannot leave using the same input method.

Your studio task

Make — Complete the page’s primary task with only Tab, Shift+Tab, arrows, Enter, Space, and Escape.

  1. Put the mouse away and complete the primary task.
  2. Record missing, hidden, illogical, or trapped focus.
  3. Repair with native controls and deliberate focus movement.
  4. Repeat backward and at 200% zoom.
Definition of done

Focus never disappears, becomes trapped, or lands beneath sticky content.

Open the interactive lesson with its workspace ↗

Knowledge check

After closing a modal dialog, where should focus usually go?
  1. The top of the page
  2. Back to the element that opened it
  3. The browser address bar
Reveal answer (B)

Returning to the trigger preserves context and lets the user continue from where they started.

A keyboard trap is…
  1. A state a person cannot leave using the keyboard
  2. An element with tabindex
  3. A page without links
Reveal answer (A)

A trap blocks keyboard escape; every state must be leaveable with the same input method.