Workshop › Sudoku › Step 27 of 28
A tap on a pad button writes that digit in the selected cell, and the last button erases.
```js
else if (y >= PAD_Y && y < PAD_Y + PAD_H && x >= 0 && x < 9 * SIZE) {
const button = Math.floor(x / PAD_W)
enter(button === 9 ? 0 : button + 1) // the last button erases
}
```Math.floor(x / PAD_W) is the button's number, 0 to 9; buttons 0–8 are digits 1–9 and button 9 erases.In pointerdown, add the pad branch after the line that selects a cell.
Skills: Keyboard and mouse input
← A number pad Build it yourself: undo →