JavaScript MouseEvent ctrlKey Property

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

What You’ll Learn

MouseEvent.ctrlKey is a read-only boolean: true if Control was held when the mouse event fired. Learn Ctrl+click patterns, Mac caveats, trackpad pinch-zoom quirks, synthetic events, and five try-it labs.

01

Kind

Instance property

02

Returns

Boolean

03

Status

Baseline Widely available

04

Access

event.ctrlKey

05

Mac label

control key

06

Family

Modifier keys

Introduction

Ctrl+click is a common power-user pattern: open in a new tab, multi-select, or a secondary action. The browser stores that state on the event as ctrlKey.

JavaScript
element.addEventListener("click", (event) => {
  console.log(event.ctrlKey); // true or false
});
💡
Mac tip

On Mac, Control+click often opens a context menu at the OS level, so ctrlKey may not reach your click handler. Command (⌘) is metaKey instead. MDN also notes pinch-zoom can set ctrlKey on simulated wheel events.

Understanding the Property

MDN: MouseEvent.ctrlKey is a read-only boolean that indicates whether the ctrl key was pressed when a given mouse event occurred.

  • Instance — read event.ctrlKey inside a handler.
  • Booleantrue pressed, false not pressed.
  • Read-only — set via constructor options on synthetic events.
  • Platform notes — Mac Control+click / trackpad pinch-zoom quirks (see above).

📝 Syntax

JavaScript
const isCtrlHeld = mouseEvent.ctrlKey;

Value

A boolean: true if Control was held during the event; otherwise false.

Setting it on synthetic events

JavaScript
const event = new MouseEvent("click", {
  ctrlKey: true,
  bubbles: true
});
console.log(event.ctrlKey); // true

⚖️ Related Modifier Properties

PropertyKeyTypical use
event.ctrlKeyControlMulti-select, open-in-new-tab patterns
event.altKeyAlt / OptionAlt+click shortcuts
event.shiftKeyShiftRange select, alternate actions
event.metaKeyMeta / Command ⌘Mac Command-click patterns

You can also call event.getModifierState("Control") for a related check.

⚡ Quick Reference

GoalCode
Read Control stateevent.ctrlKey
Ctrl+click branchif (event.ctrlKey) { … }
Synthetic Ctrl clicknew MouseEvent("click", { ctrlKey: true })
modifierState APIevent.getModifierState("Control")
MDN statusBaseline Widely available (Jul 2015)

🔍 At a Glance

Four facts about ctrlKey.

Kind
instance

On the event

Type
boolean

true / false

Status
baseline

Widely available

Mac
control

Click may be OS-handled

Examples Gallery

Examples follow MDN MouseEvent.ctrlKey. Hold Ctrl while moving or clicking to see true (platform caveats apply).

📚 Getting Started

Read ctrlKey from real pointer events.

Example 1 — Log ctrlKey on mousemove

MDN-style demo: print whether Control was held while moving.

JavaScript
const log = document.querySelector("#log");

window.addEventListener("mousemove", (e) => {
  log.textContent =
    `The ctrl key was pressed while the cursor was moving: ${e.ctrlKey}`;
});
Try It Yourself

How It Works

mousemove is a good place to observe Control on Mac, where Control+click may never reach a click listener.

Example 2 — Branch on Ctrl+Click

Use a different action when Control is held (Windows/Linux-friendly).

JavaScript
link.addEventListener("click", (e) => {
  if (e.ctrlKey || e.metaKey) {
    // ctrl (Win/Linux) or Command (Mac) — often “open related”
    console.log("Modifier+click — open related view");
    return;
  }
  console.log("Normal click — default action");
});
Try It Yourself

How It Works

Checking ctrlKey || metaKey covers Control on Windows/Linux and Command on Mac for many “power click” UX patterns.

📈 Synthetic Events & Other Modifiers

Construct events in tests and compare modifier flags.

Example 3 — Synthetic Event with ctrlKey: true

Great for unit tests without holding a physical key.

JavaScript
const event = new MouseEvent("click", {
  ctrlKey: true,
  bubbles: true
});

console.log(event.ctrlKey);     // true
console.log(event.type);        // "click"
console.log(event instanceof MouseEvent); // true
Try It Yourself

How It Works

The MouseEvent() constructor accepts modifier options. Dispatch the event if you need listeners to run.

Example 4 — Log All Modifier Keys

See Control next to Alt, Shift, and Meta on the same event.

JavaScript
document.addEventListener("click", (e) => {
  console.log({
    ctrlKey: e.ctrlKey,
    altKey: e.altKey,
    shiftKey: e.shiftKey,
    metaKey: e.metaKey
  });
});
Try It Yourself

How It Works

All four flags are independent. Users can hold several at once (for example Ctrl+Shift+click).

Example 5 — ctrlKey vs getModifierState("Control")

Two ways to ask if Control was active for the event.

JavaScript
const event = new MouseEvent("click", { ctrlKey: true });

console.log(event.ctrlKey);                      // true
console.log(event.getModifierState("Control"));   // true
console.log(event.ctrlKey === event.getModifierState("Control")); // true
Try It Yourself

How It Works

For everyday mouse handlers, event.ctrlKey is clearer and shorter. getModifierState is handy when you already use that API for other keys.

🚀 Common Use Cases

  • Ctrl+click (or Command+click) secondary actions and multi-select.
  • Logging Control state on mousemove when Mac click is OS-intercepted.
  • Unit tests that construct MouseEvent with ctrlKey: true.
  • Distinguishing physical Control from trackpad pinch-zoom wheel events.
  • Teaching the modifier family next to altKey.

🔧 How It Works

1

User holds Control

Or a gesture synthesizes Control (pinch-zoom wheel).

Input
2

Browser builds MouseEvent

Sets ctrlKey to true or false.

Event
3

Listener receives the event

Your click / mousemove / wheel handler runs.

Handler
4

Branch on event.ctrlKey

Choose default vs Ctrl-modified behavior.

📝 Notes

  • Baseline Widely available (MDN, since July 2015).
  • Not Deprecated, Experimental, or Non-standard — no status banner required.
  • On Mac, Control+click may open a context menu before your page sees the click.
  • Trackpad pinch-zoom can set ctrlKey on simulated wheel events.
  • Related: altKey, clientY, layerX, MouseEvent(), Window, JavaScript hub.

Universal Browser Support

MouseEvent.ctrlKey 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.ctrlKey

Reliable Control modifier boolean—mind Mac Control+click and pinch-zoom wheel quirks.

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
ctrlKey Excellent

Bottom line: Read event.ctrlKey in mouse handlers; consider metaKey for Mac Command-click UX.

Conclusion

event.ctrlKey tells you whether Control was held for that mouse event. Use it for Ctrl+click shortcuts, pair with metaKey for Mac Command-click, and set ctrlKey on synthetic MouseEvent objects when testing.

Continue with layerX, altKey, MouseEvent(), or the JavaScript hub.

💡 Best Practices

✅ Do

  • Read event.ctrlKey inside the mouse handler
  • Consider ctrlKey || metaKey for cross-platform power-clicks
  • Test with new MouseEvent(..., { ctrlKey: true })
  • Use mousemove when Mac Control+click is OS-stolen
  • Offer a non-modifier UI path when possible

❌ Don’t

  • Assume Control+click always reaches the page on Mac
  • Treat every wheel + ctrlKey as a physical key press
  • Confuse Control with Command (metaKey)
  • Rely only on hidden modifier shortcuts for critical actions
  • Mutate event.ctrlKey on live user events

Key Takeaways

Knowledge Unlocked

Five things to remember about ctrlKey

Boolean Control state on every mouse event.

5
Core concepts
02

Boolean

true / false

Type
🍎 03

Mac caveat

Control+click

Platform
🔧 04

Synthetic OK

options.ctrlKey

Tests
🛡️ 05

Baseline

widely available

Status

❓ Frequently Asked Questions

It is a read-only boolean on a mouse event that is true when the Control key was held down at the time of that event, and false otherwise.
No. MDN marks MouseEvent.ctrlKey as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard, so no status warning banner is needed.
On Macintosh, Control+click is often intercepted by the OS to open a context menu, so ctrlKey may not be detectable on click events. Prefer metaKey (Command) for Mac-style modifiers, or use mousemove / other events where Control is visible.
MDN notes that pinch-zooming on a trackpad can send a simulated wheel event with ctrlKey set to true. Do not assume every ctrlKey wheel event means the physical Control key was held.
Pass ctrlKey: true in the options object to new MouseEvent("click", { ctrlKey: true }). The constructed event then reports event.ctrlKey as true.
Mouse events also expose altKey, shiftKey, and metaKey. Together they describe which modifier keys were held. You can also use event.getModifierState("Control").
Did you know?

MDN warns that trackpad pinch-zoom can fire a simulated wheel event with ctrlKey: true. Zoom handlers that check e.ctrlKey must also look at other signals (for example e.deltaY) so they do not confuse pinch with a physical Control key.

Next: MouseEvent.layerX

Learn the non-standard layer-relative horizontal mouse coordinate.

layerX →

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