Find out whether or not the "SHIFT" key was pressed when a keyboard key is pressed:
Press a key on the keyboard in the input field to find out if the SHIFT key was pressed or not.
<!DOCTYPE html> <html> <body> <input type="text" onkeydown="isKeyPressed(event)"> <p id="demo"></p> <script> function isKeyPressed(event) {/*from w w w . ja v a 2s . com*/ var x = document.getElementById("demo"); if (event.shiftKey) { x.innerHTML = "The SHIFT key was pressed!"; } else { x.innerHTML = "The SHIFT key was NOT pressed!"; } } </script> </body> </html>
The shiftKey property returns a Boolean value that indicates whether or not the "SHIFT" key was pressed when a key event was triggered.
This property is read-only.
Possible values: