What key code?

Simply start typing to see the code of the key you pressed. To be used like shown below.

0

// $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();
}