This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2019.
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.
getModifierState(key)
keyA modifier key value. The value must be one of the KeyboardEvent.key values which represent modifier keys or "Accel" Deprecated . This is case-sensitive.
A boolean value.
| Specification |
|---|
| UI Events> # dom-mouseevent-getmodifierstate> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
getModifierState |
47 | 12 | 15 | 34 | 12.1 | 47 | 15 | 34 | 12.2 | 5.0 | 47 | 12.2 |
accel_support |
No | No | 32 | No | No | No | 32 | No | No | No | No | No |
MouseEvent this method belongs to.KeyboardEvent.getModifierState
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/getModifierState