Skip to content
Frontsiter

Keyboard accessibility: test your site without a mouse

If you test only with a mouse, you never see keyboard problems. A two-minute check finds skipped buttons, hidden focus, wrong Tab order, and broken dialogs.

By · Published · 3 min read

The problem

The page passed design review and automated checks, but keyboard users cannot use it. Tab skips the "Book a demo" button, nothing shows where focus is, and closing a dialog sends them back to the top of the page.

Keyboard accessibility is easy to forget when you build and test with a mouse, but it is among the most basic rules in WCAG (Level A). Many people with motor disabilities, blind people, and people who find the keyboard faster move through pages with it.

These problems usually come from custom code, such as a clickable <div>. A screenshot does not show where focus goes, and Lighthouse lists Tab order and focus traps as manual checks, outside its score.

  • Expected

    Every control is a Tab stop, in reading order, and focus shows an outline.

  • Found with the Tab key

    Tab skips “Book a demo”, a div and not a button. With the outline removed, nothing shows that “Start free trial” has focus.

With a mouse, both work the same. The numbers show where each press of Tab stops.

The fix

Below are four common mistakes, not a full list; the check at the end finds others. The samples use React, but the same HTML and CSS work in any framework.

1. Use a real button. A clickable <div> works only with a mouse; a <button> works with both. If it opens another page, use a link with href. In Hero.tsx:

tsx
// Before: Tab skips it, and Enter does nothing.
<div className="cta" onClick={openDemoForm}>Book a demo</div>

// After: Tab reaches it, and Enter and Space press it.
<button type="button" className="cta" onClick={openDemoForm}>Book a demo</button>

2. Keep focus visible. Never remove the outline without a replacement. With a sticky header, set its height as scroll-padding-top, so focus never stops under it. In globals.css:

css
/* Keyboard focus only: buttons and links skip it on a mouse click. */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

html {
  scroll-padding-top: 64px; /* the height of the sticky header */
}

The outline needs a contrast of 3:1 against its surroundings. In our test, Safari's engine still hid some items under the header; check Safari by hand.

3. Keep the Tab order the reading order. Tab follows the HTML, not the screen: row-reverse and order move items only on the screen, and a tabindex above 0 jumps ahead of everything. Keep the HTML in reading order, and use only tabindex 0 or -1.

4. Use <dialog> for modals. With showModal(), the browser moves focus into the dialog, keeps Tab out of the page behind it, closes it on Escape, and returns focus to the button that opened it. In DeleteDialog.tsx:

tsx
import { useRef } from "react";

export function DeleteDialog({ onDelete }: { onDelete: () => void }) {
  const dialogRef = useRef<HTMLDialogElement>(null);

  return (
    <>
      <button type="button" onClick={() => dialogRef.current?.showModal()}>
        Delete file
      </button>
      <dialog ref={dialogRef} aria-labelledby="delete-title">
        <h2 id="delete-title">Delete this file?</h2>
        {/* method="dialog": both buttons close the dialog. */}
        <form method="dialog">
          <button>Cancel</button>
          <button onClick={onDelete}>Delete</button>
        </form>
      </dialog>
    </>
  );
}

Check that it works

Two minutes per page, no mouse:

  • Tab stops: from the top, Tab reaches every link, button, and field, in reading order.
  • Visible focus: you can always see which item has focus.
  • Keys: Enter follows links; Enter and Space press buttons.
  • Dialogs: after Escape, one Tab lands on the control after the button that opened the dialog.
  • No trap: Tab and Shift+Tab never get stuck.
  • Safari on a Mac: turn on Safari > Settings > Advanced > "Press Tab to highlight each item on a webpage". Without it, Tab skips links.

Make this check part of "done" for every page and component.

Frontsiter uses scroll-padding-top: in an October 2026 test, removing it let Shift+Tab put focus under the sticky header 13 of 72 times on one of its articles at phone width in Chrome.

Questions or ideas?

Corrections and topic ideas are always welcome. Email hello@frontsiter.com.

Contact us