Workshop › Simon Says Colors › Step 19 of 27
A pointerdown on the canvas (mouse or finger) is turned into canvas pixels, then into a pad with padAt, and pressed.
The canvas may be shown at a different place and size on the page, so we subtract where it starts and scale.
```js
canvas.addEventListener('pointerdown', (event) => {
const rect = canvas.getBoundingClientRect()
const x = ((event.clientX - rect.left) * canvas.width) / rect.width
const y = ((event.clientY - rect.top) * canvas.height) / rect.height
const pad = padAt(x, y)
if (pad >= 0) press(pad)
})
```pointerdown fires when the canvas is pressed with a mouse or a finger.getBoundingClientRect() gives where the canvas is on the page and how big it is shown.canvas.width / rect.width: now x, y are canvas pixels.pad >= 0 skips clicks on the text strip.Under padAt, leave an empty line and write the pointerdown listener, right above the keydown listener.
Skills: Keyboard and mouse input
← Which pad is at a point? Progress and mistakes →