JavaScript Key Codes

Press any key to get corresponding code:

KeyShift
Code16

This prints the JavaScript codes for any key on your keyboard.

You can use the code number to assign an event to the key.

window.addEventListener('keydown', funcname, false);
function funcname(e) {

  /* up */ if (e.keyCode === 38   ) { exec_if_pressed() }
  /* dn */ if (e.keyCode === 40   ) { exec_if_pressed() }
  /* $ */  if (e.keyCode === 220  ) { exec_if_pressed() }
  // etc.

}