jQuery get the keycode of a key from the keyboard

Get the keycode of a key from the keyboard. The keycode for enter/return is 13. The keypress event contains the key info you might interested in. The keycode of any keys from the keyboard can be discovered by the code snippet below.

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<input id="getkeycode" />
<div id="note">Type something ^</div>	
<script type="text/javascript">
$(document).ready(function(){
  $("#getkeycode").keypress(function(event) {
    $("#note").html("<strong>" + event.which + "</strong> is the keycode corresponds to the key you just pressed.");
  });
});
</script>


Type something ^

Search within Codexpedia

Custom Search

Search the entire web

Custom Search