Handle key down event

Description

The following code shows how to handle key down event.

Example


<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {<!--  w  w w.j  a  va 2s .  c om-->
    $(window).keydown(function(event) {
      alert(event.keyCode);
    });
  });
</script>
</head>
<body>
  <p>
    <input type="text" /> <span>ja va2s.com</span>
  </p>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities