Skip to content
easeweb
Search topics

Product photo zoom that needs a mouse

A product photo zooms only while the mouse moves over it, and nothing the keyboard can reach shows the small print or detail that the zoom shows.

WCAG 2.2
SC 2.1.1A
Required by
Section 508 · EN 301 549 (EU)
Broken frame.addEventListener('mousemove', (event) => {
The accessibility problem illustrated: Motor:How do I read the small print?
01

The problem

Keyboard, switch and voice control users can't see the detail that a product photo's zoom shows

02

Try it

Read the small print on the back of the mug, first with the mouse, then with Tab alone

Show the back with its thumbnail and move the mouse over the photo. Then put the mouse aside and Tab on from the thumbnails: focus goes past the photo to Add to cart.

Apply a fix and use the control it adds; once the photo is large, the arrow keys move it.

Broken Can you fix this?

BrokenA zoom that follows the mouse

Enamel mug

$24

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Let the keyboard reach the detail the hover zoom shows

Before
BrokenA zoom that follows the mouse
<div class="gallery">  <div class="photo-frame">    <img class="photo" src="mug-front.jpg" alt="Front of the mug">  </div>  <div class="thumbs">…</div></div>
What is wrong3 points
  • The zoom starts only from mousemove, and leaves on mouseleave. No key sets off either.
  • Nothing in the gallery takes focus for the zoom: no button, no link, and the frame has no Tab stop.
  • So the keyboard can change the photo but never see its detail.
After

A Zoom button over a box that scrolls

<div class="gallery">  <button type="button" class="zoom">Zoom in</button>  <div class="photo-frame" role="region" aria-label="Zoomed photo">    <img class="photo" src="mug-front.jpg" alt="Front of the mug">  </div>  <div class="thumbs">…</div></div>
How it is fixed5 steps
  1. Add a Zoom in button over the photo, ahead of it in the page, so Tab meets it first.
  2. When it is pressed, make the photo three times as wide inside a frame that scrolls, and start from the middle of the photo.
  3. Give the frame a Tab stop while it is zoomed, and a role and a name, so Tab reaches it, a screen reader can say what it is, and the arrow keys move around the photo. Take the Tab stop off again when it zooms out.
  4. Change the button's words to Zoom out while the photo is zoomed, so it says what the next press does.
  5. Leave the zoom that follows the mouse in place as a shortcut, and switch it off while the button has the photo zoomed.

This fixes the Before and passes 2.1.1. The zoomed photo needs a large enough file behind it to keep its detail sharp at three times the width.

04

Verify the fix

5 checks, no mouse.

Test with: Keyboard, Speech input, Forced colors

0 of 5 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the gallery, its library or its theme changes.

Limits

This is a starting pattern, not a guarantee for every application. It covers how the keyboard reaches the detail a hover zoom shows. The thumbnails that change the photo are in product photo thumbnails that need a mouse or say nothing. A lightbox has its own needs for focus and closing: see modals that leave keyboard focus behind them. A photo viewer that turns or zooms by dragging, pinching or tilting is in pinch, drag and tilt gestures with no button. The browser's own zoom and a screen magnifier enlarge the photo as drawn on the page; they are the person's tools, and this guide is about the zoom the page adds.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service