Skip to content
MouseLab

How a browser actually sees your mouse

23 November 20268 min read

Your cursor is not an object the browser owns. It is a stream of position samples, produced by hardware the browser never sees and filtered by an operating system the page cannot configure. Understanding that pipeline explains why the same mouse feels different on different machines, and why no web page can tell you exactly what your mouse is doing.

The cursor is an event stream, not an object

Open the developer tools and type document in the console. There is no cursor in there. There is no object representing the mouse pointer, no property to read for its position, and no way to ask a page where the pointer is at this instant. The browser does not keep a cursor. It keeps a history of movements that already happened.

What a page receives is a sequence of pointermove events. Each one carries a snapshot of the pointer at a moment in the past: where it was, which button was down, what pressure the sensor reported, and how long the browser believes it has been since the previous event. Between those events there is no information at all. The pointer's position is not something the browser knows; it is something the browser was told, once per event, and then let go of.

That single fact explains most of the strange behaviour people notice. A script cannot ask where the mouse is right now, it can only be notified. An application that reads the last known position lags by exactly one event. And a tab in the background stops receiving events altogether, so the stream it holds when you return is a gap, not a position.

  • pointermove fires for movement; pointerdown and pointerup fire for the buttons.
  • Every event carries a timeStamp measured from the document's time origin, in milliseconds, as a double.
  • Events coalesce: several movements can be merged into one event that reports only the final position.

Where the stream actually comes from

The mouse does not send its position when you move it. It sends a position on a schedule, whether or not you moved, and each report contains only the change since the last one. A 1000 Hz mouse makes 1000 USB reports every second. A 125 Hz office mouse makes 125. That report rate is the polling rate the polling rate test on this site measures.

Between the device and the browser sit two filters you cannot see from the page. The operating system applies pointer acceleration, which means the same physical movement produces a different number of screen pixels depending on how fast you moved, and it may apply smoothing, which introduces lag. Then the browser applies its own rules about how often it is willing to deliver events to a page and which of them it merges.

The stream a page receives is therefore the product of three things: the device's report rate, the operating system's settings and the browser's internal budget. When a page says the pointer moved 400 pixels, that is the truth about what the page was told. It is not the truth about how far your hand moved.

Three coordinate systems, and they do not agree

A single movement event reports the same physical movement in three coordinate systems, and they disagree by design.

The unit is the CSS pixel, not the physical pixel. On a display with a device pixel ratio of 2, one CSS pixel is two physical pixels across. A script that measures an element with getBoundingClientRect works in CSS pixels, while a script that compares against a screen capture is working in a different unit and has to divide by the ratio to line up.

The practical consequence is that an event's coordinates describe the document at the moment it was dispatched, and the page may have scrolled since. Code that stores a pageX and later compares it with a fresh getBoundingClientRect result is comparing two different frames.

  • screenX and screenY give the position on the screen, in device pixels, including the browser window's own offset.
  • clientX and clientY give the position inside the viewport, in CSS pixels. This is the pair most page code uses.
  • pageX and pageY give the position inside the whole document, so they shift as the page scrolls.

How often you actually get events

The browser is not obliged to deliver one event per report. If a page is busy laying out at 120 frames per second and the mouse reports at 1000 Hz, most of those reports are irrelevant by the time a frame is painted, so the browser merges them.

getCoalescedEvents on a pointermove returns the list of positions that were folded into it, each with its own timeStamp. It is the closest thing to the raw stream that a web page can see. Chromium and Firefox implement it; Safari does not, and there the page sees only the merged endpoint.

pointerrawupdate is a separate event that fires for individual movement samples before coalescing, which makes it the highest-fidelity signal available to a page. It is delivered for the primary pointer only, and it is not implemented everywhere, so code that depends on it still needs a fallback.

  • One pointermove can represent many physical movements. Ask for getCoalescedEvents to see them separately.
  • requestAnimationFrame runs after the browser finished a frame. It is the right place to read a position and the wrong place to expect one event per movement.
  • A background tab receives no movement events at all, so its view of the pointer is stale until an event arrives.

Acceleration, raw input and the limits of a page

Pointer acceleration exists so that small movements can be precise while large movements stay fast. The trade-off is that the mapping from physical movement to pixels is not fixed, and it is not the same on every machine. A script reading movementX gets the delta the browser decided to apply, which already includes that curve.

The Pointer Lock API is the only way a web page can ask for unaccelerated input. While the pointer is locked, movementX and movementY report the raw delta between consecutive samples. It is also a full-screen takeover that hides the cursor and requires a user gesture, which is why a diagnostic tool cannot simply switch it on.

So a page can tell you how many pixels the pointer travelled and roughly how quickly, but it cannot tell you how far your hand actually moved, what the sensor's native resolution is, or whether the mouse applied smoothing of its own before the operating system ever saw it.

What this means when you test a mouse

This is why the tools here describe themselves as measuring what your computer received rather than what your mouse is doing. The mouse button test counts the clicks that reached the page. The polling rate test measures the spacing of the movement events the browser delivered. Neither can inspect a switch, an encoder or a sensor.

The gap between those two statements is where most confusing support threads live. A mouse with a failing left switch sends two press events for one physical press, and the browser reports both. A mouse with a worn sensor can report a perfectly regular stream of subtly wrong positions. From inside the page both look like hardware faults, and from inside the driver both look like browser bugs.

Knowing which side of that line you are on saves hours. If the events arriving at the page are wrong, the fault is in the hardware or the driver, and no browser setting will fix it. If the events are right and the application still misbehaves, the fault is in the application.

FAQ

Straight answers to the questions people ask most about this test.

Does the browser know the real position of my cursor?

No. It knows the positions it has been told about, and only at the moments it dispatched an event. Between events it does not track the pointer at all, and a background tab is not told about movement until an event reaches it again.

Why does my pointer feel smoother than the event rate suggests?

Because the screen refreshes on its own schedule. Your mouse may report 1000 times a second while the display refreshes 144 times a second. The browser merges movement events that arrive between frames, so the page sees fewer events than the device produced while the display still shows a smooth path.

Can a web page read my mouse faster than the mouse reports?

No, and it does not need to. The device is the source of the data, so the report rate is a hard ceiling. A page can ask for the individual samples behind a merged event with getCoalescedEvents, but it cannot invent samples the device never sent.

What is pointer acceleration, and can I turn it off for a test?

Pointer acceleration is the operating system's remapping of physical movement into screen pixels, so a fast flick covers more distance than a slow one. Only the Pointer Lock API exposes unaccelerated movement to a page, and it takes over the screen. Everywhere else, the numbers a page reads already include the acceleration curve.

Does a browser test prove my mouse is working correctly?

No. It proves what reached the page. A mouse can report a clean, perfectly regular stream of positions while its sensor is worn out, and a browser can deliver events perfectly while the hardware is fine. Use the browser test to rule the software side in or out, then confirm the hardware side with the manufacturer's own diagnostics.