Simply start typing to see the code of the key you pressed. To be used like shown below.
// $x is the code above
function setkeylisteners() {
document.addEventListener( 'keydown', keyDown, false );
document.addEventListener( 'keyup', keyUp, false );
}
function keyDown( key ) {
// test for shift, alt and ctrl with
// key.shiftKey, key.altKey and key.ctrlKey
if ( key.keyCode === $x ) {
// do stuff;
}
}
function keyUp( key ) {
// test for shift, alt and ctrl with
// key.shiftKey, key.altKey and key.ctrlKey
if ( key.keyCode === $x ) {
// do stuff;
}
// to turn off the preset keyboard actions, do this:
// key.preventDefault();
}