Category: >> JavaScript >> KeyCode Tester Bookmark and Share

<< lastnext >>

Snippet Name: KeyCode Tester

Description: Shows the JavaScript key code of a selected key in an alert box. Just press a key and see the value.

Comment: (none)

Author: CoderZone
Highlight Mode: JAVASCRIPT
Last Modified: December 01st, 2010

document.onkeydown = checkKeycode();
function checkKeycode(e) {
  var keycode;
  if (window.event) keycode = window.event.keyCode;
  else if (e) keycode = e.which;
  alert("The keycode is: " + keycode);
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© | users online: 6