Check key code in key down event - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:keydown

Description

Check key code in key down event

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.8.3.js"></script> 
  <script type="text/javascript">
    $(function(){// w  w w.  j ava 2 s .  co m
$(document).on('keydown', '.textBoxStyle', function(e) {
    var code = e.which || e.keyCode;
    if (code == 9) {
        console.log('destroy');
    }
});
    });

      </script> 
 </head> 
 <body> 
  <input type="text" class="textBoxStyle" value=""> 
  <input type="text" class="textBoxStyle2" value="">  
 </body>
</html>

Related Tutorials