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.
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
- Use native elements: a
buttonfor actions, anawithhreffor navigation. They are focusable and work with Enter and Space by default. - Keep the focus order logical by keeping the HTML in a logical order. Do not reorder it with a
positive
tabindex. - Show focus clearly on every interactive element. Never remove the outline without a better one.
- 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. - In dialogs and menus, move focus in when they open, keep it there, close with Escape, and return focus to where it was.
- Test every new flow with the keyboard only, before release.
Common mistakes
- A
divwith 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.
What tabindex does, and when to use it
| What it does | When to use it | |
|---|---|---|
| No tabindex on a native control | Focusable in the order of the page | Almost always |
| tabindex="0" | Adds an element to the normal order | A custom control that also handles keys |
| tabindex above 0 | Jumps ahead of everything else | Avoid: 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- 11 Nov 2026Linear: the first week of a new team
Resources
1- docsStart here
Keyboard accessible ↗
MDN Web Docs · 2025 · 6 minWhat the WCAG keyboard criteria ask for and how to meet them, including focus order and tabindex.
Tools
3- ToolFreemium
axe DevTools
Automated accessibility checks in the browser and in tests, built on the open-source axe-core engine.
- ToolFree
- ToolOpen source
Lighthouse
Open-source audits for performance, accessibility, SEO and best practices, built into Chrome.