Workshop › Conway's Game of Life › Step 31 of 32
A press at or below BAR_Y is on a button: Math.floor(point.x / BUTTON_W) finds which one, and we call the same
press as the keyboard.
```js
canvas.addEventListener('pointerdown', (event) => {
const point = toCanvas(event)
if (point.y >= BAR_Y) {
press(BUTTONS[Math.floor(point.x / BUTTON_W)])
return
}
const cell = cellAt(point)
if (!cell) return
```point.BAR_Y, Math.floor(point.x / BUTTON_W) is the button's number: x = 150 gives 1, 'Step'. We press
it and return, so no cell is painted.cellAt(point) works as before.In the pointerdown listener, replace the line const cell = cellAt(toCanvas(event)) with the new lines.
Skills: Keyboard and mouse input
← Buttons on the screen Build it yourself: a world at rest →