Get key code

Description

The following code shows how to use event.which to check the key code in keypress 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.  ja  va2  s . c  o m-->
    $("input").keypress(function(e) {
      if (e.which > 65) {
        alert(e.which);
      }
    });
  });
</script>
</head>
<body>
  <input type="text" />
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities