The read-only altKey property is a boolean: true if Alt was held when the mouse event occurred, otherwise false(MDN). On Mac keyboards this is the Option key.
Read the notes below before you rely on this property. Prefer feature detection when support is limited.
Syntax
Use event.altKey. Start with this line.
JavaScript
event.altKey
Call
What it does
event.altKey
Primary signature.
Built into the browser. Read event.altKey on a MouseEvent — no import required.
Library declarations
JavaScript
event.altKey
Parameters
This member has no parameters beyond those shown in the signature.
Return Value
Return Value
Description
*
boolean
JavaScript Examples
Example 1 — Log altKey on Click
MDN-style: print whether Alt was held.
JavaScript
document.addEventListener("click", (e) => {
console.log("The alt key is pressed:", e.altKey);
});
MouseEvent.altKey is marked Baseline Widely available on MDN (since July 2015).
✓ Baseline · Widely available
MouseEvent.altKey
Boolean: true if Alt (Option on Mac) was held during the mouse event. Some OSes may intercept Alt+click.
100%Widely available
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
altKeyExcellent
Bottom line: Safe everyday API. Prefer altKey for Alt/Option; test Alt+click on Linux desktops. See the MDN altKey reference.
Frequently Asked Questions
It is a read-only boolean on a mouse event that is true when the Alt key (Option on Mac) was held down at the time of that event, and false otherwise.
No. MDN marks MouseEvent.altKey as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
Yes. On Macintosh keyboards the Alt key is also called the Option key. MouseEvent.altKey reports that modifier.
MDN notes that some OSes reserve Alt+click for window move/resize, so the browser cannot always detect Alt during a mouse event. Treat Alt+click shortcuts carefully across platforms.
Pass altKey: true in the options object to new MouseEvent("click", { altKey: true }). The constructed event then reports event.altKey as true.
event.getModifierState("Alt") is a related check. For everyday Alt/Option, event.altKey is clearer and enough.