Skip to content
SPM Tuition
Lesson · Computer Science

Testing a small page using only the keyboard

Your page works with a mouse, but you have never checked whether it works without one.

A keyboard-only test means you put the mouse aside and try to complete every task with Tab, Enter and Space. It quickly shows controls you cannot reach, focus you cannot see and a confusing order.

This lesson belongs to web development without assessed-project substitution. It tests a practice page, so you can rehearse the method before applying it to your own work.

What should I check?

Check four things: reachability, order, visible focus and activation. Each one is a clear pass or fail.

Check Question Pass looks like
Reachability Can Tab reach every control? All controls get focus
Order Does focus move in a sensible sequence? Top to bottom, matching the layout
Visible focus Can I see where focus is? An outline or highlight
Activation Do Enter and Space do the job? Same result as a click

Worked example: a three control practice page

A fictional page has a name box, a choice of class (a dropdown) and a Show result button that writes a greeting under the form.

Test script, starting with the page loaded and no mouse use:

  1. Press Tab. Expect focus on the name box, visibly outlined.
  2. Type “Aina”. Press Tab. Expect focus on the class dropdown.
  3. Use the arrow keys to choose 4 Bestari. Press Tab. Expect focus on the button.
  4. Press Enter. Expect “Hello Aina from 4 Bestari” under the form.
  5. Press Shift and Tab. Expect focus to return to the dropdown.
Step Key Expected Actual Result
1 Tab Name box focused Name box focused Pass
3 Tab Button focused Button skipped Fail
4 Enter Greeting shown Nothing Fail

The failures in steps 3 and 4 share one cause, found next.

The mistake: a clickable element that is not a control

The button in the failed test was built like this:

<div id="show">Show result</div>

with a click handler attached in JavaScript. It looks like a button and works with a mouse. But Tab skips a plain div, and Enter does nothing because a div is not a control.

The fix is a real button element:

<button id="show">Show result</button>

The same click handler now works, Tab reaches it, and Enter and Space both activate it. Keep the appearance in CSS, since the structure and the style are separate jobs, as in separating structure, presentation and behaviour.

The second common fault: invisible focus

Some styles remove the outline with outline: none to look tidier. The page then passes reachability but fails visible focus, because the user cannot see where they are.

If you change the outline, replace it with another clear indicator, such as a thick border or a background colour change. Re-run the test after any style change.

Check yourself

Tab on a page goes name box, then button, then a dropdown that sits above the button on screen. Name the fault and one fix.

Answer

The fault is a focus order that does not match the visual order: the dropdown appears above the button but receives focus after it. Keyboard users jump around the page.

Fix: place the dropdown before the button in the HTML so the source order matches the layout, rather than moving it on screen with CSS alone. Then repeat the Tab test from the top.

What to study next

Record your keyboard test so someone else can repeat it with documenting student-authored changes with a reproducible test log. For the design side, see designing an accessible input form for a fictional task.

To practise with a teacher, see online one-to-one Computer Science tuition.

Common questions

Why test with only the keyboard?

Some users cannot use a mouse, and others prefer the keyboard. A page that works only by clicking excludes them. Keyboard testing also quickly shows elements that were built the wrong way.

Which keys do I use?

Tab moves forward through controls, Shift and Tab move back, Enter activates a button or submits a form, and Space activates a button or ticks a checkbox. Arrow keys move within a group such as radio buttons.

What is focus?

Focus marks the control that will receive the next key press. A visible outline shows where focus is. If you cannot see it, a keyboard user cannot tell where they are on the page.

Why does my clickable picture not respond to Tab?

Only controls built to be interactive, such as buttons and links, are reachable by Tab. A plain element with a click handler is not. Use a real button element, then style it as you wish.

In one-to-one Computer Science lessons, a teacher can walk through a keyboard test with you, so you see your page the way a non-mouse user does and fix it yourself.

  • Online one-to-one lessons for your child with an experienced teacher.
  • Your first class is a one-hour trial, from RM50. The fee is agreed before you book.
  • Happy with the teacher? Continue with lessons of about 1.5 hours. If not, ask for another teacher.