Workshop › Missile Command-style Defense › Step 29 of 35
When the game is over, a click or Space starts a new one with reset().
```js
canvas.addEventListener('pointerdown', (event) => {
if (state === 'over') {
reset()
return
}
document.addEventListener('keydown', (event) => {
if (event.key === ' ' && state === 'over') {
event.preventDefault()
reset()
}
})
```return stops there.' ') does the same. preventDefault() stops the browser's own action for Space (scrolling the page).pointerdown listener, write the if (state === 'over') block.}), write the keydown listener.Skills: Keyboard and mouse input, Game states
← The end Wave, ammo and messages →