views:

45

answers:

4

What's the easiest way to find the keycode for a specific key press?

Are there any good online tools that just capture any key event and show the code?

I want to try and find the key codes for special keys on a mobile device with a web browser, so an online tool would be great.

+1  A: 

The bottom of http://www.quirksmode.org/js/keys.html can show the keycode of keys you have pressed for the selected keyboard events.

KennyTM
+1  A: 

Try this:

$('#myelement').keydown(function(event) {
  var code = event.keyCode;
  alert(code);
}
Aaron Hathaway
A: 

Just googled and result

<script type="text/javascript">
function displayunicode(e){
var unicode=e.keyCode? e.keyCode : e.charCode
alert(unicode)
}
</script>
<form>
<input type="text" size="2" maxlength="1" onkeyup="displayunicode(event); this.select()" />
</form>
Ahmet Kakıcı
+1  A: 
$(function () {
  $(document).keyup(function (e) {
     alert(e.keyCode);
  });
});

Here's your online tool: http://jsbin.com/ojoku3.

Bertrand Marron