KeyboardEvent getModifierState() Method in JavaScript
KeyboardEvent getModifierState() Method in JavaScript
The getModifierState() method is used to return true if the specified modifier key was pressed or activated else it will return false. Some modifier keys that are activated only when they are being pressed down are:-
- Alt
- AltGraph
- Control
- Meta
- Shift
Some modifier keys that are activated when they are clicked and deactivated when they are clicked again are:-
- CapsLock
- NumLock
- ScrollLock
Syntax:-
Its syntax is:- event.getModifierState(modifierKey)
Return:-
Its return is:- true if specified modifier key is activated else false
Further Explanation:-
Parameter | Description |
---|---|
modifierKey | The key is to check if is activated or not. Some values are Alt, AltGraph, CapsLock, Control, Meta, NumLock, ScrollLock, Shift. |