03.5.2 · Skill in Accessibility

Keyboard interaction

Making every function usable without a mouse.

Keyboard users need a logical focus order, visible focus and no traps. Custom components such as menus and dialogs need the expected key behavior. It is one of the most common accessibility failures and one of the easiest to test.

Your status · Keyboard interaction

Saved in this browser. Sign in to keep it on every device.It colours this skill's tile on your map.

Why it matters for a product engineer

Many people use a keyboard instead of a mouse: screen reader users, people who cannot use a pointing device, people whose mouse just stopped working, and people who are simply faster with keys. A page is only accessible if everything works from the keyboard. Keyboard failures are common, and they are among the easiest to test: put the mouse away and try.

How to do it

  1. Use native elements: a button for actions, an a with href for navigation. They are focusable and work with Enter and Space by default.
  2. Keep the focus order logical by keeping the HTML in a logical order. Do not reorder it with a positive tabindex.
  3. Show focus clearly on every interactive element. Never remove the outline without a better one.
  4. If you must build a custom control, make it focusable with tabindex="0" and handle the keys people expect, the same way you handle clicks.
  5. In dialogs and menus, move focus in when they open, keep it there, close with Escape, and return focus to where it was.
  6. Test every new flow with the keyboard only, before release.

Common mistakes

  • A div with a click handler and nothing else.
  • Focus outlines removed for looks.
  • Keyboard traps, such as a widget that focus enters but cannot leave.
  • Actions that appear only on hover.

Example

WebAIM’s 2026 scan found 4.8 elements with role="button" per home page, up from 3.6 a year before. Each one is a control that was not built as a button. To work from the keyboard, each needs focus, Enter and Space handling and a visible focus style: the things a native button has for free.

Side by side

What tabindex does, and when to use it

What it doesWhen to use it
No tabindex on a native controlFocusable in the order of the pageAlmost always
tabindex="0"Adds an element to the normal orderA custom control that also handles keys
tabindex above 0Jumps ahead of everything elseAvoid: the order stops matching the page

Most keyboard problems disappear when the HTML is in a logical order and uses native controls.

ReportedMDN Web Docs, Keyboard accessible

Sources: Keyboard accessible (MDN Web Docs) ↗ · The WebAIM Million, 2026 report (WebAIM) ↗

In practice

Real products

Resources

1
  • docsStart here
    Keyboard accessible ↗
    MDN Web Docs · 2025 · 6 min

    What the WCAG keyboard criteria ask for and how to meet them, including focus order and tabindex.

Tools

3
Tools for Accessibility