ctrlKey Event Attribute
Complete Event Object Reference
Definition and Usage
The ctrlKey event attribute returns a Boolean value that indicates whether or not the "CTRL" key was
pressed when an event was triggered.
Syntax
event.ctrlKey=true|false|1|0
|
Example
The following example alerts whether or not the "CTRL" key was pressed when a
mouse button was clicked:
<html>
<head>
<script type="text/javascript">
function isKeyPressed(event)
{
if (event.ctrlKey==1)
{
alert("The CTRL key was pressed!")
}
else
{
alert("The CTRL key was NOT pressed!")
}
}
</script>
</head>
<body onmousedown="isKeyPressed(event)">
<p>Click somewhere in the document.
An alert box will tell you if you
pressed the CTRL key or not.</p>
</body>
</html>
|
Try-It-Yourself Demos
ctrlKey - Check whether or not the CTRL key was pressed
Complete Event Object Reference
|