Javascript examples for DOM:Key Event
The ctrlKey property indicates if the "CTRL" key was pressed.
This property is read-only.
A Boolean, indicating if the "CTRL" key was pressed.
The following code shows how to find out if the "CTRL" key was pressed:
<!DOCTYPE html> <html> <body> <input type="text" onkeydown="isKeyPressed(event)"> <p id="demo"></p> <script> function isKeyPressed(event) {/*w w w .ja va2 s . c om*/ var x = document.getElementById("demo"); if (event.ctrlKey) { x.innerHTML = "The CTRL key was pressed!"; } else { x.innerHTML = "The CTRL key was NOT pressed!"; } } </script> </body> </html>