MouseEvent: getModifierState() method
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The MouseEvent.getModifierState()
method returns the current state of the specified modifier key: true
if the modifier is active (i.e., the modifier key is pressed or locked), otherwise, false
.
See KeyboardEvent.getModifierState()
for details.
Syntax
js
getModifierState(key)
Parameters
key
-
A modifier key value. The value must be one of the
KeyboardEvent.key
values which represent modifier keys or"Accel"
Deprecated . This is case-sensitive.
Return value
A boolean value.
Specifications
Specification |
---|
UI Events # dom-mouseevent-getmodifierstate |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
getModifierState | ||||||||||||
"Accel" parameter |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- Non-standard. Check cross-browser support before using.
- Deprecated. Not for use in new websites.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
See also
- The
MouseEvent
this method belongs to. KeyboardEvent.getModifierState