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 the document of KeyboardEvent.getModifierState() for details.
Syntax
var active = event.getModifierState(keyArg);
Returns
A Boolean
Parameters
keyArg- A modifier key value. The value must be one of the
KeyboardEvent.keyvalues which represent modifier keys or"Accel". This is case-sensitive.
Specifications
| Specification | Status | Comment |
|---|---|---|
| Document Object Model (DOM) Level 3 Events Specification The definition of 'getModifierState()' in that specification. |
Obsolete | Initial definition. |
Browser compatibility
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.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
getModifierState | Chrome Full support 47 | Edge Full support 12 | Firefox Full support Yes | IE ? | Opera Full support Yes | Safari ? | WebView Android Full support 47 | Chrome Android Full support 47 | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android Full support 5.0 |
"Accel" parameter | Chrome No support No | Edge No support No | Firefox ? | IE ? | Opera ? | Safari ? | WebView Android No support No | Chrome Android No support No | Firefox Android ? | Opera Android ? | Safari iOS ? | Samsung Internet Android No support No |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Non-standard. Expect poor cross-browser support.
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.
- Deprecated. Not for use in new websites.
See also
- The
MouseEventthis method belongs to. KeyboardEvent.getModifierState
