function keyDown(e) {
  if (keyStatus.hasOwnProperty(e.key)) {
    keyStatus[e.key] = true;
  }
  if (e.repeat) {
    e.preventDefault();
    return;
  }
  if (mode !== modes.PLAYING) {
    return;
  }
  switch (e.key) {
    case('ArrowUp'):
    case('x'):
      actionRotate(false);
      break;
    case('Control'):
    case('z'):
      actionRotate(true);
      break;
    case('ArrowLeft'):
      actionMove(false);
      break;
    case('ArrowRight'):
      actionMove(true);
      break;
    case('ArrowDown'):
      // Move down one, and increase falling speed by 20x.
      actionDown();
      clearInterval(fallPid);
      fallPid = setInterval(actionDown, speed / 20);
      break;
    case(' '):
      actionDrop();
      break;
    default:
      return;
  }
  if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
    stopAutoRepeat();
    initAutoRepeat(e.key);
  }
  e.preventDefault();
}
// User pressed a key to start an action.
User pressed a key to start an action.
User pressed a key to start an action .
function keyDown(e) {
  if (keyStatus.hasOwnProperty(e.key)) {
    keyStatus[e.key] = true;
  }
  if (e.repeat) {
    e.preventDefault();
    return;
  }
  if (mode !== modes.PLAYING) {
    return;
  }
  switch (e.key) {
    case('ArrowUp'):
    case('x'):
      actionRotate(false);
      break;
    case('Control'):
    case('z'):
      actionRotate(true);
      break;
    case('ArrowLeft'):
      actionMove(false);
      break;
    case('ArrowRight'):
      actionMove(true);
      break;
    case('ArrowDown'):
      actionDown();
      clearInterval(fallPid);
      fallPid = setInterval(actionDown, speed / 20);
      break;
    case(' '):
      actionDrop();
      break;
    default:
      return;
  }
  if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
    stopAutoRepeat();
    initAutoRepeat(e.key);
  }
  e.preventDefault();
}
function keyDown ( e ) { if ( keyStatus . hasOwnProperty ( e . key ) ) { keyStatus [ e . key ] = true ; } if ( e . repeat ) { e . preventDefault ( ) ; return ; } if ( mode !== modes . PLAYING ) { return ; } switch ( e . key ) { case ( 'ArrowUp' ) : case ( 'x' ) : actionRotate ( false ) ; break ; case ( 'Control' ) : case ( 'z' ) : actionRotate ( true ) ; break ; case ( 'ArrowLeft' ) : actionMove ( false ) ; break ; case ( 'ArrowRight' ) : actionMove ( true ) ; break ; case ( 'ArrowDown' ) : actionDown ( ) ; clearInterval ( fallPid ) ; fallPid = setInterval ( actionDown , speed / 20 ) ; break ; case ( ' ' ) : actionDrop ( ) ; break ; default : return ; } if ( e . key === 'ArrowLeft' || e . key === 'ArrowRight' ) { stopAutoRepeat ( ) ; initAutoRepeat ( e . key ) ; } e . preventDefault ( ) ; }
User pressed a key to start an action.
User pressed a key to start an action .
// Move down one, and increase falling speed by 20x.