Designing a Website That Works With a Keyboard

Try this on your own website. Put the mouse to one side, load the home page and press Tab. Can you see where you are? Can you get to the contact form and send it?

Plenty of people get around the web that way, using Tab, the arrow keys and Enter. Some prefer it and plenty have no choice because a mouse just doesn’t work for them. If your site falls over for those visitors they’ll leave, and most of the fixes come down to decent habits during the build.

Who’s using the keyboard

The rules here come from the Web Content Accessibility Guidelines (WCAG), which are published by the World Wide Web Consortium. The W3C’s explanation of the WCAG keyboard success criterion lists who benefits. Blind people are on it, since a mouse relies on eye and hand coordination. So are people with low vision who have trouble following a pointer, and people with hand tremors.

It also helps anyone using alternate keyboards or keyboard emulators. The W3C names speech input, sip and puff systems, on screen keyboards and scanning software, which all send keyboard style commands to the page. If something on your site only works with a mouse, those people can’t use it.

The speech input one is interesting. We’ve written about voice search optimisation and how people talk to search engines, but some people use their voice to move around the sites they land on as well. Build for the keyboard and you’ve helped them too.

The basic rules

WCAG success criterion 2.1.1 Keyboard is a Level A requirement. It says all functionality of the content should be operable through a keyboard interface, without needing specific timings for individual keystrokes. So every menu, button, slider and form on your site should work without a mouse.

There’s a narrow exception for functions that depend on the path of the user’s movement, like freehand drawing. The W3C is clear that dragging something to a spot or resizing a window doesn’t count, because those only care about where you start and where you finish.

The usual trouble spots are dropdown menus that only open on hover, image galleries, carousels and custom booking widgets. Chat popups and cookie banners are regular offenders. Run each of them past the keyboard before the site goes live.

Next is 2.1.2 No Keyboard Trap, also at Level A. If you can tab into a part of the page, you have to be able to tab back out. If getting out needs anything other than the usual arrow or Tab keys, the visitor has to be told how. The W3C notes that traps often happen with embedded content and custom widgets. Holding focus inside something is allowed in some cases, a modal dialog for example, as long as there’s a clear way out. Escape is the common exit, and a visible close button that works with Enter is a sensible extra.

Then order. WCAG 2.4.3 Focus Order is Level A, and where the order affects meaning or operation, focusable items should get focus in an order that keeps their meaning and use intact. The W3C’s example of a fail is a form that jumps around between unrelated sections. An easy test is whether the Tab order follows the reading order of the page.

Seeing where you are

WCAG 2.4.7 Focus Visible is a Level AA requirement, and it says any keyboard operable interface should have a mode where the keyboard focus indicator is visible. That’s normally an outline or highlight around whatever link or button is active. The W3C adds that it shouldn’t disappear after a time limit.

A common problem is a theme that strips out the browser’s default focus outline for looks. It might look a bit cleaner to a mouse user. Keyboard users lose their place completely. Taking the outline away with nothing to replace it is the problem, so if your designer doesn’t like the default, ask for a custom focus style that suits your brand and stands out against your colours.

Your theme makes a big difference here. When you go through the questions to ask before choosing a WordPress theme, add keyboard access to the list and tab through the theme demo before you pay for it. If you can’t see where you are, keep looking.

WCAG 2.2 also added 2.4.11 Focus Not Obscured (Minimum) at Level AA. When something gets keyboard focus, it shouldn’t be entirely hidden by content the site owner put there. The W3C page on focus not obscured lists the usual causes, which are sticky headers and footers, non modal dialogs and cookie banners. A cookie banner fails if it completely covers something that has focus.

The W3C describes a few fixes. CSS scroll padding can stop a sticky header covering the focused item. A cookie banner can be made modal, or set to close when it loses focus. And content that pushes the page down, like an accordion, avoids the overlap in the first place.

Skip links

WCAG 2.4.1 Bypass Blocks is Level A. It asks for a way to skip blocks of content that repeat on every page, like the main menu. One technique the W3C lists is a skip link at the top of each page that jumps straight to the main content. Headings at the start of each section and ARIA landmarks are others.

Skip links can stay hidden until they get focus, so they don’t change how the page looks. On a site with a big menu, they save keyboard users a lot of key presses on every single page. It’s a small job for whoever builds your site.

Testing it yourself

You don’t need special software for a first go. Automated checkers can join your other digital marketing tools later on. For now, mouse aside, home page open:

  • Press Tab and see whether a skip link or the first menu item gets a visible outline.
  • Keep pressing Tab and check the order follows the layout.
  • Open menus, sliders and popups with Enter, Space or the arrow keys.
  • Try closing any popup with Escape, then check you can keep going.
  • Watch for focus vanishing behind a sticky header or cookie banner.
  • Fill in and send your contact form with only the keyboard.

Write down whatever fails and send it to whoever looks after your site, then do the same on your busiest pages. Plugin and theme updates can quietly break things that used to work, so it’s worth having keyboard access on the list of things a website audit should be assessing and checking it now and then.

This is general information about web design. The keyboard rules here come from WCAG 2.2, and accessibility standards get updated over time, so check the current W3C guidance for your own project.