Javascript getModifierState() KeyboardEvent MethodJavascript getModifierState() KeyboardEvent uses to know which keypresses are on the keyboard. The event returns true if modifiers keys are pressed or clicked off the keyboard. We can use the pressed, clicked key, and the keyboard event activates the function. SyntaxThe syntax uses the javascript tag to use getModifierState() KeyboardEvent. Description: Modifier_key is used to press or click the keyboard button. Key pressed modifiers Modifier keys work or are triggered when it is activated by pressing down:
Key clicked modifiers Modifier keys work or are triggered when it is clicked and deactivated:
ExamplesThe following examples show the getModifierState() KeyboardEvent with methods. Example 1: The example shows which key is pressed from the keyboard and shows event information. We can use other keyboard events and javascript functions to get event information. The keyboard press event shows and operates the alt key button. Output The keydown event shows alt keys functionality. Example 2: The example shows which key is pressed from the keyboard and shows shift event information. If the shift key is pressed down, the output shows true otherwise false. The keyboard event shows and operates the shift press button. Output The keydown event shows alt keys functionality. Example 3: The example shows which key onclick from the keyboard and shows number lock event information. The keyboard event shows and operates the numlock button. Output The keydown event shows alt keys functionality. Example 4 The example shows which key is down from the keyboard and shows capslock events information. The keyboard event shows and operates the capslock button. Output The keydown event shows alt keys functionality. ConclusionThe getModifierState keyboard event works when the particular key operates with the function for the user interactive functionality. The key function works with the web page's up, down, and Press events. Next TopicJavaScript only Number Regex |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India