How can I make a custom listbox usable without a mouse?
Quick answer
Use a native <select> if its standard option-selection behavior meets your needs; it provides a labeled form control and built-in browser interaction. If you build a custom listbox, define how keyboard focus moves, how selection changes, and how each state is shown. Support Up and Down Arrow, and consider Home, End, and type-ahead for longer lists. Test the component with a keyboard. [S1] [S2]
The question, the details, the next step.
A practical checklist
Use a labeled native
<select>unless a custom listbox has a specific interaction need.Specify where focus goes when the listbox receives keyboard focus.
Implement Up and Down Arrow movement; consider Home and End for lists over five options and type-ahead for longer lists.
Choose and document whether focus movement also changes selection.
Make focused and selected states distinguishable, including when they belong to different options.
For multiple selection, define and test the selection model and its keyboard controls.
Test the real component with a keyboard and in the browsers and operating systems that matter to your audience.
A few more useful answers
Does a listbox have to select an option as soon as focus moves to it?
No. For single selection, the pattern permits selection to follow focus or to remain separate. Pick one behavior and make focus and selection clear to users. [S1]
Are Home, End, and type-ahead required for every listbox?
The guidance describes Home and End as optional but strongly recommended for lists with more than five options, and type-ahead as recommended, especially for lists with more than seven. [S1]
Will a native select behave exactly the same on every device?
No such guarantee is established here. Native controls provide built-in interaction, but keyboard details—particularly for multiselect controls—and appearance can vary by browser and operating system. [S2]
Sources
References used for this guide.
- [S1] W3C WAI-ARIA APG: Listbox Pattern w3.org · Checked
- [S2] MDN: HTML select element developer.mozilla.org · Checked
