HTML | DOM KeyboardEvent shiftKey Property
The KeyboardEvent shiftKey property in HTML DOM is a read-only property and used to return a Boolean value which indicates the SHIFT key is pressed or not. The KeyboardEvent shiftKey property returns true if the SHIFT key is pressed, otherwise returns false.
Syntax:
event.shiftKey
Below program illustrates the KeyboardEvent shiftkey Property in HTML DOM:
Example: This example check whether the SHIFT key is pressed or not.
<!DOCTYPE html> <html> <head> <title> HTML DOM KeyboardEvent shiftKey Property </title> </head> <body> <h1>GeeksforGeeks</h1> <h2>KeyboardEvent shiftKey Property</h2> <p> Check whether the SHIFT key is pressed or not </p> <input type="text" onkeydown="keyboard(event)"> <p id="test"></p> <!-- script to check shift key is pressed or not --> <script> function keyboard(event) { var a = document.getElementById("test"); if (event.shiftKey) { a.innerHTML = "The Shift key has been pressed!"; } else { a.innerHTML = "The Shift key has not been pressed!"; } } </script> </body> </html> |
Output:
Before Press the key:

After Press the key:

Supported Browsers: The browser supported by KeyboardEvent shiftKey Property are listed below:
- Opera
- Internet Explorer
- Google Chrome
- Firefox
- Apple Safari
Recommended Posts:
- HTML | DOM TouchEvent shiftKey Property
- HTML | KeyboardEvent which Property
- HTML | DOM KeyboardEvent key Property
- HTML | DOM KeyboardEvent location Property
- HTML | DOM KeyboardEvent metaKey Property
- HTML | DOM KeyboardEvent keyCode Property
- HTML DOM | KeyboardEvent altKey Property
- HTML | DOM keyboardEvent charCode Property
- HTML | DOM KeyboardEvent code Property
- JavaScript | MouseEvent shiftKey Property
- HTML | DOM KeyboardEvent
- HTML | DOM KeyboardEvent getModifierState() Method
- HTML | DOM Map name Property
- HTML | DOM specified Property
- HTML | DOM URL Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

