Javascript examples for DOM:Mouse Event
The ctrlKey property tells if "CTRL" key was pressed when a mouse event was triggered.
This property is read-only.
A Boolean, indicating if the "CTRL" key was pressed when the mouse event occured.
The following code shows how to find out whether or not the "CTRL" key was pressed when a mouse button is clicked:
<!DOCTYPE html> <html> <body onmousedown="isKeyPressed(event)"> <p>Click somewhere in the document. </p> <script> function isKeyPressed(event) {/*from ww w .j ava 2 s .c o m*/ if (event.ctrlKey) { console.log("The CTRL key was pressed!"); } else { console.log("The CTRL key was NOT pressed!"); } } </script> </body> </html>