Find out whether or not the "CTRL" key was pressed when a mouse button is clicked:
Click somewhere in the document.
<!DOCTYPE html> <html> <body onmousedown="isKeyPressed(event)"> <p id="demo"></p> <script> function isKeyPressed(event) {// w w w . ja va2 s .c o m if (event.ctrlKey) { document.getElementById("demo").innerHTML = "The CTRL key was pressed!"; } else { document.getElementById("demo").innerHTML = "The CTRL key was NOT pressed!"; } } </script> </body> </html>
The ctrlKey property returns a Boolean value that indicates whether or not the "CTRL" key was pressed when a mouse event was triggered.
This property is read-only.
Possible values: