function keyDown(e) {
  if (e.key === 'Enter' || e.key === ' ') {
    if (document.getElementById('shield').style.display === 'block') {
      reset();
    }
    e.preventDefault();
  }
  if (e.code >= 'Numpad1' && e.code <= 'Numpad9') {
    var i = Number(e.code.slice(-1));
    // Convert from 789/456/123 layout to 0-8.
    i = [null, 6, 7, 8, 3, 4, 5, 0, 1, 2][i];
    if (enabled && board[i] === EMPTY) {
      humanPlay(i);
    }
  }
}
// Key presses to clear shield, or play.
Key presses to clear shield, or play.
Key presses to clear shield or play .
function keyDown(e) {
  if (e.key === 'Enter' || e.key === ' ') {
    if (document.getElementById('shield').style.display === 'block') {
      reset();
    }
    e.preventDefault();
  }
  if (e.code >= 'Numpad1' && e.code <= 'Numpad9') {
    var i = Number(e.code.slice(-1));
    i = [null, 6, 7, 8, 3, 4, 5, 0, 1, 2][i];
    if (enabled && board[i] === EMPTY) {
      humanPlay(i);
    }
  }
}
function keyDown ( e ) { if ( e . key === 'Enter' || e . key === ' ' ) { if ( document . getElementById ( 'shield' ) . style . display === 'block' ) { reset ( ) ; } e . preventDefault ( ) ; } if ( e . code >= 'Numpad1' && e . code <= 'Numpad9' ) { var i = Number ( e . code . slice ( - 1 ) ) ; i = [ null , 6 , 7 , 8 , 3 , 4 , 5 , 0 , 1 , 2 ] [ i ] ; if ( enabled && board [ i ] === EMPTY ) { humanPlay ( i ) ; } } }
Key presses to clear shield, or play.
Key presses to clear shield or play .
// Convert from 789/456/123 layout to 0-8.