JavaScript MouseEvent movementY Property

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline Newly available
Instance property

What You’ll Learn

MouseEvent.movementY is a read-only number: how far the pointer moved vertically since the previous move event. Learn when it is non-zero, how it relates to screenY, unit caveats, safer DIY deltas, and five try-it labs.

01

Kind

Instance property

02

Returns

Number (delta Y)

03

Status

Baseline Newly available

04

Live on

mousemove

05

Pair with

movementX

06

Else

Usually 0

Introduction

Absolute positions like clientY answer “where is the cursor?” movementY answers “how far did it move up or down since the last move?”—perfect for pans, look controls, and drawing tools.

JavaScript
document.addEventListener("mousemove", (event) => {
  console.log(event.movementY); // delta since previous mousemove
});
💡
Beginner tip

Think of movementY as a tiny “speedometer” for vertical travel between two move events—not a ruler from the top edge of the window.

Understanding the Property

MDN: movementY provides the difference in the Y coordinate of the mouse (or pointer) between the given move event and the previous move event of the same type. In other words, it is computed like currentEvent.screenY - previousEvent.screenY.

  • Instance — read event.movementY in a handler.
  • Delta — positive when moving down, negative when moving up (typical).
  • Move-only — zero on click and most other mouse events.
  • Unit caution — browsers may disagree on pixel units (see Notes).

📝 Syntax

JavaScript
const dy = mouseEvent.movementY;

Value

A number for the vertical movement since the previous same-type move event. Always 0 on other MouseEvent types (and on pointer events other than pointermove / pointerrawupdate).

Safer DIY delta (portable units)

JavaScript
let prevScreenY = null;

document.addEventListener("mousemove", (e) => {
  const dy = prevScreenY == null ? 0 : e.screenY - prevScreenY;
  prevScreenY = e.screenY;
  console.log({ movementY: e.movementY, diyDy: dy });
});

⚖️ movementY vs Absolute Y Properties

PropertyMeaningBest for
movementYDelta Y since last moveRelative motion / look / pan
clientYY in the viewportTooltips, hit-testing in window
screenYY on the monitorMulti-monitor / DIY deltas
movementXDelta X since last moveHorizontal twin of movementY

⚡ Quick Reference

GoalCode
Read vertical deltaevent.movementY
Read both deltas{ x: e.movementX, y: e.movementY }
Listen for motionaddEventListener("mousemove", …)
DIY portable deltae.screenY - prevScreenY
MDN statusBaseline Newly available (Jan 2026)

🔍 At a Glance

Four facts about movementY.

Kind
instance

On the event

Type
number

Delta Y

Status
baseline

Newly available

Pair
movementX

Horizontal twin

Examples Gallery

Examples follow MDN MouseEvent.movementY. Move the mouse to see non-zero deltas; click to confirm zeros.

📚 Getting Started

See deltas on real mousemove events.

Example 1 — Log movementX / movementY

MDN-style demo: prepend each delta line while you move.

JavaScript
const log = document.getElementById("log");

function logMovement(event) {
  log.insertAdjacentHTML(
    "afterbegin",
    `movement: ${event.movementX}, ${event.movementY}
` ); while (log.childNodes.length > 128) log.lastChild.remove(); } document.addEventListener("mousemove", logMovement);
Try It Yourself

How It Works

Each mousemove reports how far the pointer traveled since the previous mousemove. Cap the log length so the page stays responsive.

Example 2 — Zero on Non-Move Events

Prove that a plain click reports movementY === 0.

JavaScript
document.addEventListener("click", (e) => {
  console.log({
    type: e.type,
    movementY: e.movementY, // 0
    clientY: e.clientY      // absolute position still set
  });
});
Try It Yourself

How It Works

Absolute coordinates still update on click. Movement deltas only apply to move-style events.

📈 Portable Deltas & Simple UX

Follow MDN’s unit warning and build tiny interactive demos.

Example 3 — DIY Delta from screenY

MDN suggests computing your own delta when units must stay consistent.

JavaScript
let prev = null;

document.addEventListener("mousemove", (e) => {
  const diyDy = prev == null ? 0 : e.screenY - prev;
  prev = e.screenY;
  console.log({ movementY: e.movementY, diyDy });
});
Try It Yourself

How It Works

Storing the previous screenY gives you a delta in the same unit family as screenY, which can be more predictable across engines.

Example 4 — Accumulate Vertical Travel

Sum absolute movementY to estimate how far the cursor has traveled.

JavaScript
let traveled = 0;
const out = document.getElementById("out");

document.addEventListener("mousemove", (e) => {
  traveled += Math.abs(e.movementY);
  out.textContent = `Vertical travel ≈ ${Math.round(traveled)}`;
});
Try It Yourself

How It Works

Using Math.abs counts up and down motion the same. Reset traveled when you start a new gesture.

Example 5 — Simple Vertical Pan

Move a box with movementY while the mouse button is held.

JavaScript
const box = document.getElementById("box");
let dragging = false;
let y = 40;

box.addEventListener("mousedown", () => { dragging = true; });
window.addEventListener("mouseup", () => { dragging = false; });

window.addEventListener("mousemove", (e) => {
  if (!dragging) return;
  y += e.movementY;
  box.style.transform = `translateY(${y}px)`;
});
Try It Yourself

How It Works

Relative motion keeps the drag smooth even if the cursor briefly leaves the box. Pair with movementX for free 2D dragging.

🚀 Common Use Cases

  • Pointer-lock look / camera controls in games.
  • Canvas drawing tools that react to stroke velocity or direction.
  • Drag-to-pan maps, timelines, and image viewers.
  • Gesture metrics (how far the cursor traveled this frame).
  • Teaching relative vs absolute mouse coordinates next to clientY.

🔧 How It Works

1

Pointer moves

Browser records the new screen position.

Input
2

Delta vs previous move

Roughly screenY - previous.screenY.

Compute
3

mousemove event fires

movementY carries that vertical delta.

Event
4

Your handler uses the delta

Pan, rotate, draw, or accumulate travel.

📝 Notes

  • Baseline Newly available (MDN, since January 2026)—verify older browsers if needed.
  • Not Deprecated, Experimental, or Non-standard — no status banner required.
  • MDN warning: unit systems for movementY / screenY can differ by browser and OS.
  • Prefer DIY screenY/clientY deltas when pixel units must match everywhere.
  • Related: movementX, clientY, MouseEvent(), Window, JavaScript hub.

Modern Browser Support

MouseEvent.movementY is Baseline Newly available (MDN: since January 2026). Logos use the shared browser-image-sprite.png sprite from this project. Older browsers may need fallbacks or DIY screenY deltas.

Baseline · Newly available

MouseEvent.movementY

Vertical move delta—mind unit differences; DIY screenY deltas are safer for portable apps.

Modern Newly available
Google Chrome Supported in current releases
Full support
Mozilla Firefox Supported in current releases
Full support
Apple Safari Supported in current releases
Full support
Microsoft Edge Supported · Chromium
Full support
Opera Supported in modern versions
Full support
Internet Explorer Not a modern Baseline target
No support
movementY Modern

Bottom line: Use movementY on mousemove; fall back to screenY deltas when targeting older engines.

Conclusion

event.movementY is the vertical distance the pointer traveled since the previous move event. Use it for relative motion UX, remember it is usually 0 outside move events, and consider DIY screenY deltas when unit consistency matters.

Continue with movementX, clientY, mozInputSource, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Read movementY on mousemove / pointer move events
  • Pair with movementX for 2D relative motion
  • Offer a DIY screenY delta when units must match
  • Test on the OSes and browsers you ship to
  • Reset accumulators when a gesture ends

❌ Don’t

  • Expect non-zero values on plain click events
  • Assume identical pixel units in every browser
  • Confuse deltas with absolute clientY positions
  • Skip fallbacks if you support older engines
  • Mutate event.movementY on live user events

Key Takeaways

Knowledge Unlocked

Five things to remember about movementY

Vertical move delta—relative motion, not absolute position.

5
Core concepts
📈 02

Delta Y

since last move

Type
🔄 03

Move events

else usually 0

When
⚠️ 04

Unit caution

DIY if needed

Portability
🛡️ 05

Baseline

newly available

Status

❓ Frequently Asked Questions

It is a read-only number: the difference in the Y coordinate of the pointer between this move event and the previous move event of the same type. Conceptually: current.screenY − previous.screenY.
No. MDN marks MouseEvent.movementY as Baseline Newly available (since January 2026). It is not Deprecated, Experimental, or Non-standard, so no status warning banner is needed. Older browsers may still lack reliable support.
It is always zero on MouseEvent types other than mousemove, and on PointerEvent types other than pointermove or pointerrawupdate. A plain click reports 0.
Browsers disagree on whether movementY uses physical pixels, logical pixels, or CSS pixels—unlike a strict reading of the spec. For portable deltas, many apps compute their own delta from successive screenY or clientY values.
movementX is the horizontal counterpart. Together they describe how far the pointer moved since the last move event of the same type.
Pointer-lock look controls, vertical pans, drawing tools, and any UI that needs relative vertical movement rather than absolute cursor position.
Did you know?

movementY is defined in the Pointer Lock specification family. With the pointer locked (cursor hidden and confined), relative deltas keep working even when the OS cursor would have hit the edge of the screen—exactly what first-person look controls need.

Next: MouseEvent.mozInputSource

Learn Firefox’s non-standard input device type on mouse events.

mozInputSource →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful