Workshop › Conway's Game of Life › Step 11 of 32
Now we see the rules at work: each press of the N key calls step() once, and the loop shows the new generation.
```js
document.addEventListener('keydown', (event) => {
if (event.key.toLowerCase() === 'n') step()
})
```addEventListener('keydown', ...) runs the arrow function every time a key goes down.event.key is the key, like 'n' or 'N'; .toLowerCase() makes it small, so both work.Write the listener above function draw() {, with an empty line after it. Run, click the game, press N a few times.
Skills: Keyboard and mouse input
← Draw again and again Count the generations →