Workshop › Hangman › Step 27 of 36
After the end, Enter, Space or a click on the game starts a new word.
```js
document.addEventListener('keydown', (event) => {
if (state !== 'playing' && (event.key === 'Enter' || event.key === ' ')) {
event.preventDefault()
newWord()
return
}
// ...
})
canvas.addEventListener('pointerdown', () => {
if (state !== 'playing') newWord()
})
```event.preventDefault() stops Space from scrolling the page.pointerdown fires when the mouse button or a finger goes down on the canvas.keydown listener, at the very top (under its first line), write the if block.}), leave an empty line and write the pointerdown listener. Press Run.Skills: Keyboard and mouse input, Game states
← The end message Never the same word twice →