var keyMap = {
  88: 103,
  90: 105,
  17: 99,
  13: 97,
  38: 104,
  40: 98,
  37: 100,
  39: 102
};

$(document).bind("keydown", function(evt) {
  var code = evt.keyCode;
  if (player == 1) { nes.keyboard.keyDown(evt); }
  if (player == 2 && keyMap[code]) { evt.preventDefault(); sendKey("keydown", keyMap[code]); }
});

$(document).bind("keyup", function(evt) {
  var code = evt.keyCode;
  if (player == 1) { nes.keyboard.keyUp(evt); }
  if (player == 2 && keyMap[code]) { evt.preventDefault(); sendKey("keyup