Workshop › Asteroids › Step 40 of 41
Space now does two jobs: it starts a new game when the game is over, and fires otherwise. newGame already knows how to
put everything back.
```js
if (event.key === ' ' && !event.repeat) {
if (state === 'over') newGame()
else shoot()
}
```if becomes a block with an inner if ... else.In the keydown listener, replace the Space line with the block.
Skills: Keyboard and mouse input, Game states
← GAME OVER Build it yourself: hyperspace →