JavaScript MouseEvent screenY Property

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

What You’ll Learn

MouseEvent.screenY is a read-only number: the mouse’s vertical position relative to the screen (monitor), not the page or the viewport. Learn how it differs from clientY and pageY, and practice with five try-it labs.

01

Kind

Instance property

02

Returns

Number (CSS px)

03

Status

Baseline Widely available

04

Origin

Screen top edge

05

Pair with

screenX

06

Scroll

Does not affect screenY

Introduction

Sometimes you care about where the pointer sits on the physical display—not where it is inside the scrolled page or the browser chrome. That is screenX (horizontal) and screenY (vertical): coordinates in screen space.

JavaScript
document.addEventListener("mousemove", (event) => {
  console.log(event.screenY); // pixels from screen top
});
💡
Beginner tip

Move the browser window up or down on your monitor: clientY stays tied to the window, while screenY tracks the pointer across the whole display.

Understanding the Property

MDN: screenY provides the vertical coordinate (offset) of the mouse pointer in screen coordinates. Pair it with screenX for a full screen point.

  • Instance — read event.screenY in a handler.
  • Number — CSS pixels; a floating-point double.
  • Screen-relative — independent of page scroll.
  • Read-only — set via constructor options on synthetic events only.

📝 Syntax

JavaScript
const y = mouseEvent.screenY;

Value

A double floating-point value in pixels (MDN). Early versions of the specification defined this as an integer; modern engines expose a double for subpixel precision.

⚖️ screenY vs Other Y Coordinates

PropertyMeasured fromScroll / window
screenYScreen (monitor) topIgnores page scroll; follows screen
clientYViewport topTied to the browser window
pageYDocument topGrows with vertical scroll
offsetYTarget padding edgeLocal to the hit element

Mental model: use screenY for display-relative work, clientY for viewport UI, and pageY for document markers. Pair screenY with screenX for a full screen point.

⚡ Quick Reference

GoalCode
Read screen Yevent.screenY
Screen point{ x: event.screenX, y: event.screenY }
Compare systemsscreenY / clientY / pageY
Approx window topscreenY - clientY
MDN statusBaseline Widely available (Jul 2015)

🔍 At a Glance

Four facts about screenY.

Kind
instance

On the event

Type
double

CSS pixels

Origin
screen

Top edge = 0

Status
baseline

Widely available

Examples Gallery

Examples follow MDN MouseEvent.screenY. Move the mouse and (if you can) drag the browser window vertically to see screen vs viewport values.

📚 Getting Started

Read screenX / screenY from live pointer events.

Example 1 — Log Screen and Client Coordinates

MDN-style demo: show screen and client positions on mousemove.

JavaScript
const screenLog = document.querySelector("#screen-log");
document.addEventListener("mousemove", logKey);

function logKey(e) {
  screenLog.innerText = `
    Screen X/Y: ${e.screenX}, ${e.screenY}
    Client X/Y: ${e.clientX}, ${e.clientY}`;
}
Try It Yourself

How It Works

Each move prints both coordinate systems. screenX / screenY are monitor-relative; clientX / clientY stay relative to the viewport.

Example 2 — Build a Full Screen Point

Combine screenX and screenY into one object.

JavaScript
document.addEventListener("click", (e) => {
  const point = { x: e.screenX, y: e.screenY };
  console.log(point);
});
Try It Yourself

How It Works

A click captures both axes at once. Use this shape when you need a single screen-space position for logs or tests.

📈 Synthetic Events, Compare & Deltas

Construct coordinates, compare systems, estimate window offset.

Example 3 — Synthetic Event with screenY

Useful in tests when you need a known screen point.

JavaScript
const event = new MouseEvent("click", {
  screenX: 640,
  screenY: 360,
  bubbles: true
});

console.log(event.screenX); // 640
console.log(event.screenY); // 360
Try It Yourself

How It Works

Pass numeric screenX / screenY to MouseEvent() when tests assert screen-space positions.

Example 4 — Compare screenY, clientY, pageY

Three Y systems on the same move.

JavaScript
document.addEventListener("mousemove", (e) => {
  console.log({
    screenY: e.screenY, // monitor
    clientY: e.clientY, // viewport
    pageY: e.pageY,     // document
    scrollY: window.scrollY
  });
});
Try It Yourself

How It Works

With scrollY === 0, pageY and clientY often match, while screenY is usually larger because it includes the window’s offset on the monitor.

Example 5 — Estimate Window Top with screenY - clientY

Rough teaching math: screen minus viewport hints at the window’s top offset.

JavaScript
document.addEventListener("mousemove", (e) => {
  // Approximate: how far the viewport is from the screen's top
  const approxWindowTop = e.screenY - e.clientY;
  console.log(approxWindowTop);
});
Try It Yourself

How It Works

Dragging the window up or down changes screenY - clientY while keeping clientY stable for the same point inside the page. Real apps rarely need this; it is a clear way to feel the difference between the two systems.

🚀 Common Use Cases

  • Debugging pointer position relative to the physical display.
  • Teaching screen vs viewport vs document coordinate systems.
  • Building a full screen point with screenX + screenY.
  • Synthetic events in tests with known screenX / screenY.
  • Understanding how window chrome offsets relate to screen space.

🔧 How It Works

1

Pointer moves on the display

The OS knows the cursor position in screen pixels.

Input
2

Browser keeps screen coordinates

Also maps to viewport and document for clientY / pageY.

Mapping
3

MouseEvent stores screenY

Your listener reads the vertical screen coordinate.

Event
4

Use screen coordinates

Compare with clientY / pageY when teaching or debugging.

📝 Notes

  • Baseline Widely available (MDN, since July 2015).
  • Not Deprecated, Experimental, or Non-standard — no status banner required.
  • Value type is a floating-point double in modern engines.
  • Page scroll does not change screenY; window position on the monitor does.
  • Related: screenX, clientY, pageY, MouseEvent(), Window, JavaScript hub.

Universal Browser Support

MouseEvent.screenY is Baseline Widely available across modern browsers (MDN: since July 2015). Logos use the shared browser-image-sprite.png sprite from this project.

Baseline · Widely available

MouseEvent.screenY

Reliable screen-relative Y for monitor-space pointer positions.

Universal Widely available
Google Chrome Full support · Desktop & Mobile
Full support
Mozilla Firefox Full support · Desktop & Mobile
Full support
Apple Safari Full support · macOS & iOS
Full support
Microsoft Edge Full support · Chromium
Full support
Opera Full support · Modern versions
Full support
Internet Explorer Supported in modern IE versions
Full support
screenY Excellent

Bottom line: Read event.screenY for monitor-space vertical position; pair with screenX for a full screen point.

Conclusion

event.screenY gives you the vertical mouse position relative to the screen. Use it when you need display space; reach for clientY for viewport UI and pageY for document markers.

Continue with screenX, shiftKey, clientY, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use screenY for screen-space vertical positions
  • Pair with screenX for a full screen point
  • Compare with clientY / pageY when teaching
  • Remember page scroll does not change screenY
  • Prefer clientY for most in-page UI

❌ Don’t

  • Confuse screenY with viewport clientY
  • Assume page scroll changes screenY
  • Place absolute page markers with screen coordinates
  • Assume it equals offsetY inside an element
  • Mutate event.screenY on live user events

Key Takeaways

Knowledge Unlocked

Five things to remember about screenY

Screen-relative Y that ignores page scroll.

5
Core concepts
🔢 02

Double

CSS pixels

Type
🖥️ 03

Screen

top edge origin

Origin
📈 04

Scroll-free

ignores page scroll

Behavior
🛡️ 05

Baseline

widely available

Status

❓ Frequently Asked Questions

It is a read-only number: the vertical mouse position in CSS pixels relative to the top edge of the user’s screen (monitor), not the browser window or the document.
No. MDN marks MouseEvent.screenY as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard, so no status warning banner is needed.
clientY is measured from the viewport’s top edge (the visible browser window). screenY is measured from the screen’s top edge. Moving or resizing the window changes how they relate.
pageY is relative to the document and includes vertical scroll. screenY ignores page scroll—it is screen-space vertical position.
They form a full screen point: { x: event.screenX, y: event.screenY }. screenX is horizontal from the screen’s left; screenY is vertical from the screen’s top.
A double floating-point number of pixels. Early specs defined it as an integer; modern engines expose a double for subpixel precision.
Did you know?

Like screenX, early specs treated screenY as an integer pixel count. Modern engines expose a floating-point double, so you may see fractional values when subpixel positioning is involved—still a JavaScript Number either way.

Next: MouseEvent.shiftKey

Learn the boolean Shift key flag for mouse events and Shift+click patterns.

shiftKey →

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