In JavaScript, the mousemove event fires when a pointing device moves while its hotspot is inside the element (MDN). It fires whether or not any buttons are pressed — and it can fire at a very high rate. The event type is a MouseEvent.
Register a listener with addEventListener. Check readiness and browser support before you rely on this event.
Lesson from MDN. Rate depends on mouse speed and machine load.
Implication. Avoid heavy DOM or network work per event.
Fix. Throttle, or only act while dragging.
Compatibility
Browser Support
Element mousemove is Baseline Widely available (MDN: since July 2015). Safe for mouse tracking and drag demos in modern and older evergreen browsers.
✓ Baseline · Widely available
Element mousemove
MouseEvent when the pointer moves inside an element — long-established across browsers.
99%Widely available
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
mousemoveBaseline
Bottom line: Keep handlers light. Gate drag work behind mousedown/mouseup. Prefer pointermove when you need touch/pen too.
Frequently Asked Questions
It fires when a pointing device moves while its hotspot is inside the element (MDN). It can fire whether or not any mouse buttons are pressed.
No. MDN marks Element mousemove as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
A MouseEvent. Useful fields include clientX, clientY, offsetX, offsetY, movementX, movementY, and buttons.
It can fire at a very high rate depending on mouse speed, machine speed, and other work (MDN). Keep handlers light, throttle updates, or only track while dragging.
Use mousedown to start, mousemove to draw while a flag is true, and mouseup (often on window) to stop — the MDN canvas pattern.
For unified mouse/touch/pen tracking, pointermove plus setPointerCapture is often a better modern model. mousemove remains widely used for mouse-only demos.