EveryRole

Keyboard accessibility testing in ten minutes

Keyboard accessibility testing needs no tool. Put the mouse away, press Tab, and check that you can reach everything, see where you are, and never get stuck.

Keyboard accessibility testing is the cheapest accessibility test there is. Put the mouse out of reach, open your most important page, and press Tab. You are checking three things: you can reach every control, you can always see which one you are on, and you never get stuck.

It takes about ten minutes for one journey, it needs no tool, and it stands in for a lot of people: those who can’t use a mouse, screen reader users (who drive everything from the keyboard), and anyone with a broken trackpad.

The keys for keyboard accessibility testing

KeyWhat it should do
TabMove to the next link, button or field
Shift + TabMove to the previous one
EnterFollow a link, press a button, send a form
SpacePress a button, tick a checkbox
Arrow keysMove inside a group: radio buttons, a select, tabs, a menu
EscapeClose a dialog or a menu

On a Mac, check one setting first, or the test fails for the wrong reason. Safari only tabs to links if “Press Tab to highlight each item on a webpage” is on (in its Advanced settings), and macOS has a “Keyboard navigation” switch in its keyboard settings that other browsers follow.

How to test keyboard navigation: the routine

We ran it on our practice app’s new item form.

Our practice app, keyboard only: five presses of Tab to reach the first field, then type, Tab, Tab, Enter.

The item was created without touching the mouse, so the form passes the main test. It also showed two smaller things, which is typical of this routine in our experience.

1. Can you reach everything?

Tab through the whole page, top to bottom, and count off the controls you would click with a mouse. Each one must take focus at some point.

What gets missed is anything that isn’t a real link, button or field. A <div> with a click handler looks like a button and Tab passes straight over it. The same goes for custom dropdowns, star ratings, drag handles, “x” icons that close things, and cards where the whole card is clickable.

Then press Enter or Space on each button you reach. Taking focus is half of it. It also has to work.

2. Can you see where you are?

At every press, something on the screen must show the focus. This is the “focus visible” rule, and it fails more quietly than the others, because nothing is broken. You just can’t tell where you are.

Our practice app shows both outcomes on one page. On the menu links, the browser’s outline is impossible to miss (the picture at the top of this post). On the Create button, it is the same outline, drawn dark on a dark green button:

The practice app's new item form with the keyboard focus on the Create button. The outline around the dark green button is thin and dark, and hard to see
Focus is on Create. Would you have known? The outline is there, dark on dark.

That is a finding. Nobody removed the outline. A button colour was chosen and nobody looked at it with focus on it.

The worse version is deliberate: a stylesheet with outline: none, added years ago because someone disliked the ring after a mouse click. If you find that line, replace it with a :focus-visible style, which shows the ring for keyboard users and not after a click.

3. Tab order testing: does the order make sense?

Focus should move the way you read: top to bottom, and in the direction your language reads. You notice a wrong order at once, because the outline jumps. The usual causes are a layout that places things visually in another order than they are in the page’s code, and old tabindex values above zero.

On our form the order was right: menu, Name, Note, Create. But it took five presses to reach the first field, because the four menu links come first on every page. With four links that is a small tax. With a forty-link header it is the reason “skip to content” links exist: a link, first in the page, shown when it takes focus, that jumps past the menu. Our practice app has none.

4. Can you get out?

Open everything that opens: a dialog, a dropdown, a date picker, a chat bubble. Then check, with the keyboard only:

  • Focus moved into the thing that opened. If it stayed behind on the page, you are now tabbing through controls you can’t see.
  • While a dialog is open, Tab stays inside it. This is the one place a trap is correct.
  • Escape closes it, and focus goes back to the button that opened it, not to the top of the page.

The trap to look for is the opposite kind: a widget you can tab into and not out of. Embedded editors, maps and video players are where we’d look first. If Tab does nothing and Shift + Tab does nothing, that’s the failure, and for a keyboard user the page ends there.

5. Send the form wrong

Leave a required field empty and press Enter. Where does focus go? The good answers are: to the first field with an error, or to a summary of errors at the top that links to each field. The bad answer is nowhere: an error appears somewhere on the screen and focus stays on the button. A sighted keyboard user can recover from that. A screen reader user may hear nothing at all. It is the empty form test with one more thing to look at.

What to write down

For each finding, one line: the page, the control, what happened. “New item, the Create button, focus outline nearly invisible.” “Settings, the plan dropdown, can’t be opened with Enter or Space.” That list is short the first time and it is exactly what a developer needs.

Then pick the journey to repeat. A full keyboard pass over every page takes a long time. One pass over sign-up and over the main thing your app does is ten minutes each, and those are the two that decide whether someone can use the app at all. They belong on your launch checklist.

What code can check, and what EveryRole checks

Of the five checks, a script can decide the first half of the first with confidence: press Tab from the top of the page, note everything that takes focus, and list the controls that never did.

That is what EveryRole’s page checks do, on every page of your app in a full run, as each kind of user. It presses Tab from the top, up to a stated maximum of presses. Once focus comes back round to a control it already reached, every control that was never focused is reported: “A control on this page can’t be reached with the keyboard”. If the maximum is reached first, the rest is “could not tell”, never a pass.

It doesn’t judge whether the outline can be seen, whether the order makes sense, or whether a dialog gives focus back. Those are checks 2 to 5, and pressing each button you reach. They are the ten minutes this post is about. We listed which accessibility checks code can and can’t decide in the accessibility testing checklist.

Keep reading

Accessibility and phones

Find broken links and dead buttons on your site

How to find broken links on a website you own: ask for each internal link once, slowly, and read the answer. Then the links a checker calls fine that aren’t.

6 min read