Recent chats
ASKGEEZ Q&A GUIDETechnology & devices

How can I build a website menu that works with both keyboard and pointer?

Quick answer

For links that take people to pages or sections of your site, use a conventional navigation list with ordinary links. Don’t add application-style menu behavior just because the design is called a menu. Choose that widget pattern when the interface offers menu-like commands and genuinely needs its interaction model; it brings additional keyboard and focus requirements. Test the chosen pattern with both keyboard and pointer, including opening, choosing, and leaving it.

LET’S WORK THROUGH IT

The question, the details, the next step.

Question

I’m building a site header with links like Home, Services, and Contact. Should I implement a menu widget so it works well with both a mouse and a keyboard?

Geez

Usually, no. If those items are links to destinations on your website, build a conventional navigation list containing ordinary links. A site navigation structure is typically conveyed as a list, with ordinary links in the list; an unordered list is suitable when the order does not matter. [S1] Calling the design a “menu” does not by itself make it an application-style menu.

Keep the interaction appropriate to the task: users choose a destination, rather than issue a command inside an application. That distinction helps avoid adding widget behavior the interface does not need. The relevant pattern depends on what the controls do, not just their appearance.

Follow-up question

What if the navigation opens a small panel with more links when I click or point at a category?

Geez

First decide whether the panel is still navigation or is a collection of application-style commands. A panel containing more destinations can still be organized as navigation links; its visual appearance alone does not establish that it should use an application-menu pattern. [S1]

For a pointer-and-keyboard review, test the panel’s actual tasks rather than assuming one input method is enough. With a pointer, check that a person can reach and choose each destination and dismiss or move away from the panel as designed. With a keyboard, check that the same destinations can be reached and activated, and that a person can leave the panel and continue through the page. Write down the intended behavior first so the two tests can be compared. These are practical test prompts, not a substitute for checking the final implementation against the chosen pattern.

Follow-up question

When would an application-style menu be the right choice, and what extra behavior would I be taking on?

Geez

Use that pattern when the choices are genuinely menu commands or comparable application actions, rather than ordinary links to site destinations. The WAI-ARIA Authoring Practices describe menu widgets as collections of choices such as actions or functions, modeled on desktop application menus. They require managed focus and arrow-key navigation; Tab and Shift+Tab leave the menu instead of moving through its items. [S2]

That is a different interaction contract from a list of destination links, so adopting it adds keyboard behavior to implement and test. Don’t select it solely because the panel looks like a compact dropdown. The pattern descriptions establish that distinction and the menu widget’s listed keyboard model; they do not establish that a particular implementation is accessible, nor do they specify every detail of your site’s design.

Follow-up question

Can you give me a small decision guide and test plan I can use before handing this to a developer?

Geez

Use this decision note as a copyable starting point:

Purpose: [destinations / application commands] Chosen pattern: [navigation list / application-style menu] Pointer tasks: [open, choose, dismiss or move away] Keyboard tasks: [reach, choose, leave, continue] Unresolved behavior: [describe what still needs a decision]

Worked example, assuming the header contains links to Home, Services, and Contact: record “Purpose: destinations” and “Chosen pattern: navigation list with ordinary links.” Then test each destination with a pointer and with a keyboard, and note any item that cannot be reached or activated as intended. If a panel opens, add its opening and leaving behavior to both test lists. If the purpose is instead a set of application commands, record why that interaction calls for the application-style pattern and test its required focus and arrow-key behavior. [S1] [S2]

A test plan is a way to find gaps, not proof that the finished site meets every accessibility requirement. Check the actual interface and implementation, and seek a qualified accessibility review if the pattern or results are unclear.

A practical checklist

  • Write down whether each item leads to a site destination or performs an application action.

  • Use a conventional list of ordinary links for site navigation unless the interaction genuinely calls for an application-style menu.

  • List the pointer tasks: reach the control, open any panel, choose an item, and dismiss or move away as intended.

  • Repeat the task list with a keyboard; check that choices can be reached and activated and that users can leave and continue.

  • If using an application-style menu, explicitly test managed focus, arrow-key navigation, and leaving with Tab or Shift+Tab.

  • Record unclear behavior and review the implemented interface, not just the design.

A few more useful answers

Does a dropdown automatically need application-style menu behavior?

No. A dropdown’s appearance does not determine its interaction pattern. If it contains destinations, it can remain navigation; choose an application-style menu when the choices and behavior genuinely call for that widget pattern. [S1] [S2]

What is the main keyboard difference with an application-style menu?

The described menu pattern uses managed focus and arrow-key navigation, while Tab and Shift+Tab leave the menu rather than moving among its items. [S2]

What should I do if I cannot tell which pattern fits?

Describe what each item does and what a person should be able to accomplish, then compare that purpose with the navigation-list and application-menu distinction. The guidance does not determine the right answer for every custom interface, so seek an accessibility review if the interaction remains ambiguous.

Sources

References used for this guide.

  1. [S1] WAI Menus Tutorial: Menu Structure
    w3.org · Checked
  2. [S2] WAI-ARIA Authoring Practices: Menu and Menubar Pattern
    w3.org · Checked

YOUR QUESTION. YOUR DETAILS.

Let’s work through your situation.

Get a tailored answer or help with your next task. Starts at $1, with a quote before you pay.

Ask your own question
← Back to Geez at Work