event.metaKey is a Boolean property that tells you whether the Meta modifier was held when the event fired — Command (⌘) on Mac, Windows key on PC. This tutorial covers the official click demo, Cmd+click links, modifier key comparisons, multi-select UI, and keyboard handlers.
01
Property
event.metaKey
02
Returns
Boolean
03
Official
true / false
04
Mac
Command ⌘
05
Windows
Windows key
06
Since 1.0.4
Read-only
Fundamentals
Introduction
Many user actions combine a pointer or key event with a modifier key — Command-click to open a link in a new tab, Shift-click to extend a selection, Ctrl/Cmd shortcuts in editors. The browser exposes which modifiers were down through properties on the event object.
event.metaKey specifically reports the META key. jQuery passes it through on its normalized event object since version 1.0.4. The official demo displays true or false when you click while holding or releasing the Meta key.
Concept
Understanding event.metaKey
This property answers one question: was the Meta modifier held when this event fired?
Meta not pressed — event.metaKey is false.
Meta held — true for that click, mousedown, keydown, or related dispatch.
Read-only — not a function; do not call with parentheses.
Platform mapping — Mac Command and Windows key both surface as metaKey in supporting browsers.
💡
Beginner Tip
For cross-platform “primary shortcut” behavior (open in new tab, save, etc.), many tutorials use event.metaKey || event.ctrlKey. Use metaKey alone when you specifically need the Meta/Command/Windows key state.
Foundation
📝 Syntax
Official jQuery API form (since 1.0.4) — a property, not a method:
jQuery
event.metaKey
// typical pattern:
$( "#target" ).on( "click", function ( event ) {
if ( event.metaKey ) {
// Meta / Command / Windows key was held
}
});
Parameters
None — metaKey is a property, not a function.
Return value
Boolean — true if the META key was pressed when the event fired; otherwise false.
Command+S (Mac) → status shows save message, metaKey: true
On Windows, Ctrl+S sets ctrlKey — extend with (metaKey || ctrlKey) for parity
How It Works
Keyboard events expose the same modifier properties as mouse events. metaKey stays true while the Meta/Command key is held during the keydown dispatch.
Applications
🚀 Common Use Cases
Cmd+click links — open URLs in a new tab when metaKey is true.
Multi-select lists — additive selection with Meta/Ctrl held.
Canvas / diagram tools — Meta+drag for alternate tool modes.
Custom shortcuts — detect Meta+key chords in keydown handlers.
Analytics — tag events when users hold modifiers during clicks.
Accessibility docs — display platform-specific shortcut labels using modifier state.
🧠 How metaKey Works
1
User input
User clicks or presses a key while holding Command, Windows key, or other modifiers.
Input
2
Browser builds event
Native event gets metaKey: true/false plus sibling modifier flags.
Native
3
jQuery handler
Your .on() callback receives the normalized event — read event.metaKey.
Handler
4
✓
Branch your UI
Open new tabs, extend selection, or run shortcuts based on the Boolean.
Important
📝 Notes
Available since jQuery 1.0.4 — a Boolean property, not a method.
Read-only — reflects keyboard state at dispatch time.
Mac Command (⌘) sets metaKey; Windows Windows key sets metaKey in supporting browsers.
Do not confuse with ctrlKey — on Mac, Control and Command are different keys.
Works on mouse and keyboard events that expose modifier state (e.g. click, keydown).
For cross-platform primary shortcuts, consider event.metaKey || event.ctrlKey.
Compatibility
Browser Support
event.metaKey is forwarded on jQuery’s event object since jQuery 1.0.4+. Underlying support comes from the DOM MouseEvent and KeyboardEvent modifier properties — consistent across modern browsers jQuery targets.
✓ jQuery 1.0.4+ · all browsers
jQuery event.metaKey
Detect the Meta modifier on events.
100%Universal
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
metaKeyBoolean
Bottom line: Read event.metaKey in handlers — true when Command / Windows key was held.
Wrap Up
Conclusion
event.metaKey tells you whether the Meta modifier was held when the event fired — Command on Mac, Windows key on PC. The official demo prints true or false on each click.
Use it for Cmd+click behavior, multi-select UIs, and keyboard shortcuts — and pair with ctrlKey when you need cross-platform parity.
Read event.metaKey in click handlers for Cmd+click UX
Use metaKey || ctrlKey for cross-platform shortcut parity
Document shortcuts per platform in UI tooltips
Combine with shiftKey for range-selection patterns
Test on Mac and Windows hardware when modifiers matter
❌ Don’t
Call event.metaKey() with parentheses — it is a property
Assume metaKey means Ctrl on Windows — check both or test
Overwrite or assign to event.metaKey
Rely on metaKey alone for save/copy shortcuts on all OSes
Forget touch devices — modifiers apply to keyboard/mouse combos
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about metaKey
Detect the Meta modifier on jQuery events.
5
Core concepts
⌘01
metaKey
Boolean property
API
Mac02
Command
⌘ on Mac
Map
demo03
Official
true / false
Demo
link04
Cmd+click
New tab
Use
ctrl05
ctrlKey
Cross-platform
Pair
❓ Frequently Asked Questions
event.metaKey is a Boolean property on the jQuery event object. It is true when the META modifier key was pressed at the time the event fired, and false otherwise. Available since jQuery 1.0.4.
On Macintosh keyboards, metaKey maps to the Command key (⌘). On Windows keyboards, metaKey maps to the Windows key. The property name is always metaKey — check the platform or document the shortcut for users.
They report different modifier keys. On Mac, Command-click often sets metaKey while Ctrl-click sets ctrlKey. On Windows, Ctrl+click sets ctrlKey; the Windows key may set metaKey. Do not assume metaKey equals "primary shortcut key" on every OS — test or branch on both when needed.
Mouse events such as click, mousedown, and mouseup expose metaKey when the Meta/Command/Windows key is held. Keyboard events such as keydown and keyup also expose metaKey alongside key, code, and other modifiers.
No. metaKey is read-only — it reflects keyboard state when the browser dispatched the event. You cannot flip it to simulate a modifier; trigger real events or branch on the actual property value.
Many web apps use (event.metaKey || event.ctrlKey) for "primary modifier + click/key" shortcuts so Mac Command and Windows Ctrl behave similarly. metaKey alone is correct when you specifically need the Meta/Command/Windows key state.
Did you know?
The name metaKey comes from historical “Meta” keys on Lisp workstations. Apple mapped it to Command; browsers kept the property name for compatibility. jQuery has exposed it since 1.0.4 alongside ctrlKey, shiftKey, and altKey.