Example of Event Object in HTML DOM

The ctrlKey event attribute returns a Boolean value that indicates whether or not the "Ctrl" key was pressed when an event was triggered. The following example shows that  how we can do this

<html>
<head>
<script type="text/javascript">
function iskeypress(event)
{
if (event.ctrlKey==1)
  {
  alert("The Ctrl key is pressed now you may continue....")
  }
else
  {
  alert("OOps The Ctrl key is not pressed")
  }
}
</script>
</head>

<body onmousedown="iskeypress(event)">


</body>
</html>


There are lots of event attribute we can use it here like altKey,shiftKey,metaKey...
Ebook Download
View all
Learn
View all