Javascript examples for DOM:Key Event
The shiftKey property indicates whether or not the "SHIFT" key was pressed.
This property is read-only.
A Boolean, whether the "SHIFT" key was pressed.
The following code shows how to find out whether or not the "SHIFT" key was pressed:
<!DOCTYPE html> <html> <body> <input type="text" onkeydown="isKeyPressed(event)"> <p id="demo"></p> <script> function isKeyPressed(event) {//from w w w .j a va 2s. co m 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>