Keyboard navigation test cases for web forms
Put the mouse aside and fill in the whole form with the keyboard. Some people use a form only this way, and some bugs exist only on this path, such as a check that runs on a mouse click and not on Enter. Testing tools that set field values from a script never press a key, so they do not reach these bugs at all.
Before you start
On a Mac, Safari moves focus with Tab only between fields by default and skips buttons and links. Turn on "Press Tab to highlight each item" in Safari's Advanced settings, or use Option+Tab, or test in another browser. Otherwise every button that Tab skips ends up in your report.
Tab order
Click in the address bar, then press Tab until focus reaches the first field. Keep pressing Tab and write down each stop until focus leaves the form. Then go back with Shift+Tab.
- The order should match the order on the screen: top to bottom, and left to right within a row. A field that comes later in the page source than where it is drawn gets its focus late.
- Every control that the mouse can use should be a stop: fields, checkboxes, the submit button, a "show password" toggle, a link to the terms.
- Nothing invisible should be a stop. Focus that vanishes for one press of Tab has landed on something hidden: a field moved off-screen, a closed menu, a dialog that is not open.
- Focus must be able to leave. A widget that keeps focus inside it, such as a rich text editor or a date picker, should let Tab or Escape out. WCAG calls the failure a keyboard trap (2.1.2).
A positive tabindex in the HTML, such as tabindex="3", puts that element
ahead of everything with the default order, wherever it sits on the page. Search the page source for
it when the order looks wrong.
Can you see where focus is?
At every stop, you should be able to tell which control has focus without moving the mouse. The
usual cause of a missing ring is CSS such as outline: none with nothing put in its
place. Check the submit button and the checkboxes in particular: designers often restyle them, and
the restyled version may have no focus state. WCAG 2.4.7 asks for a visible focus indicator.
Keys for each control
Native HTML controls come with these keys. A control rebuilt from div elements has
none of them until someone writes the handlers, so a custom dropdown or date picker needs the same
checks as a native one.
| Control | Keys | Expected |
|---|---|---|
| Text field | Typing, Backspace, Home, End | Text changes as typed, the caret moves |
| Checkbox | Space | Toggles |
| Radio group | Tab, then arrow keys | Tab enters the group once, at the selected option; arrows move and select |
| Select | Arrow keys; Alt+Down to open the list | The option changes; on some systems the arrows change it with the list closed |
| Button | Enter and Space | Same result as a click |
| Link | Enter | Opens it; Space scrolls the page instead |
| Dialog | Escape | Closes it, and focus returns to the control that opened it |
A select whose arrow keys change the value with the list closed fires a change for every option you pass. A form that reloads part of the page or sends a request on each change does it once per arrow press. Watch the Network tab while you move through a long list.
Three ways to submit
Fill the form in correctly, then break one rule, for example leave a required box unticked. Submit it three ways:
- Click the submit button.
- Press Enter in a text field.
- Tab to the submit button and press Space.
All three should end the same way: the same error, and no request to the server. In a plain form
the browser makes them the same: Enter in a text field fires a click on the submit button. They
split when the page handles keys itself. A script may listen for Enter and submit by a route of its
own, with its own copy of the checks, or a click handler may look at mouse details that a key press
does not have (event.detail is 0 for a click made with Enter or Space). Write down which
way you used in the report, since a developer who clicks will not see the bug.
Two details of Enter are worth a test of their own. In a textarea, Enter should add a
line, not submit. And a form with no submit button and more than one text field does nothing on Enter,
as the HTML standard specifies. A button with type="button", or one built from a
div, does not count as a submit button. Then press Enter twice quickly in a text field and count the requests. The
double submit guide covers what to look for.
Typing versus filling
A field gets its value in different ways, and each fires different browser events:
| How the value arrives | Key events | Input event |
|---|---|---|
| Typed, key by key | Yes, for every character | Yes |
| Pasted | Only for the paste shortcut, not for the characters | Yes, once |
| Browser autofill | No | Yes |
| Set by a script | No | No |
Code that formats or limits a value can listen to any of these. A handler on key presses that
upper-cases or cuts the text runs for typed input and not for pasted input; a check on the
input event runs for both but not for a value set by a script. So enter the same value
twice, typed and pasted, and compare what the field holds afterwards and what the request carries.
Browser automation tools differ in the same way: Playwright's fill() sets the value and
fires one input event, while pressSequentially() presses each key.
This is also why AI testing agents, which mostly fill fields from scripts, miss keyboard bugs. The guide on what agents miss has the numbers from a set of runs.
Focus after an error
Submit with an error and look at where focus is now. The helpful place is the first field with an error, or a summary of errors at the top that links to each field. Focus left on the submit button, with the message out of view above it, makes a keyboard user press Shift+Tab back through the form to find the problem.
Worse is focus on nothing. If the page redraws the form after the error, the focused element may be removed, and the next Tab starts again from the top of the page.
Then correct the field and press Tab out of it. The message should go away without another submit, the same as with the mouse.
A short set
With five minutes for a form: one full pass with Tab and Shift+Tab, noting the order and any stop without a visible ring; the three ways to submit with one rule broken; one field typed and then pasted with the same value; and where focus lands after an error.
Open the practice form
More guides: sign-up and login forms · silent failures and stale screens · all guides