function detectKeyInput () {
  if (upKey.isDown) {
    dY = -1
  } else if (downKey.isDown) {
    dY = 1
  } else {
    dY = 0
  }
  if (rightKey.isDown) {
    dX = 1
    if (dY === 0) {
      facing = 'east'
    } else if (dY === 1) {
      facing = 'southeast'
      dX = dY = 0.5
    } else {
      facing = 'northeast'
      dX = 0.5
      dY = -0.5
    }
  } else if (leftKey.isDown) {
    dX = -1
    if (dY === 0) {
      facing = 'west'
    } else if (dY === 1) {
      facing = 'southwest'
      dY = 0.5
      dX = -0.5
    } else {
      facing = 'northwest'
      dX = dY = -0.5
    }
  } else {
    dX = 0
    if (dY === 0) {
      // facing="west"
    } else if (dY === 1) {
      facing = "south"
    } else {
      facing = "north"
    }
  }
}
// Assign direction for character & set x, y speed components.
Assign direction for character & set x, y speed components.
Assign direction for character & set x y speed components .
function detectKeyInput () {
  if (upKey.isDown) {
    dY = -1
  } else if (downKey.isDown) {
    dY = 1
  } else {
    dY = 0
  }
  if (rightKey.isDown) {
    dX = 1
    if (dY === 0) {
      facing = 'east'
    } else if (dY === 1) {
      facing = 'southeast'
      dX = dY = 0.5
    } else {
      facing = 'northeast'
      dX = 0.5
      dY = -0.5
    }
  } else if (leftKey.isDown) {
    dX = -1
    if (dY === 0) {
      facing = 'west'
    } else if (dY === 1) {
      facing = 'southwest'
      dY = 0.5
      dX = -0.5
    } else {
      facing = 'northwest'
      dX = dY = -0.5
    }
  } else {
    dX = 0
    if (dY === 0) {
    } else if (dY === 1) {
      facing = "south"
    } else {
      facing = "north"
    }
  }
}
function detectKeyInput ( ) { if ( upKey . isDown ) { dY = - 1 } else if ( downKey . isDown ) { dY = 1 } else { dY = 0 } if ( rightKey . isDown ) { dX = 1 if ( dY === 0 ) { facing = 'east' } else if ( dY === 1 ) { facing = 'southeast' dX = dY = 0.5 } else { facing = 'northeast' dX = 0.5 dY = - 0.5 } } else if ( leftKey . isDown ) { dX = - 1 if ( dY === 0 ) { facing = 'west' } else if ( dY === 1 ) { facing = 'southwest' dY = 0.5 dX = - 0.5 } else { facing = 'northwest' dX = dY = - 0.5 } } else { dX = 0 if ( dY === 0 ) { } else if ( dY === 1 ) { facing = "south" } else { facing = "north" } } }
Assign direction for character & set x, y speed components.
Assign direction for character & set x y speed components .
// facing="west"