Workshop › Simon Says Colors › Step 18 of 27
To play with the mouse we must know which pad is under a point. padAt(x, y) answers -1 in the text strip, and
otherwise 0 to 3 from the half of the board the point is in.
```js
function padAt(x, y) {
if (y < TOP) return -1
return (y - TOP < HALF ? 0 : 2) + (x < HALF ? 0 : 1)
}
```y < TOP) there is no pad: -1.Under press, leave an empty line and write padAt (above the keydown listener).
Skills: Functions
← Play with the keyboard Play with the mouse →