Workshop › Sudoku › Step 10 of 28
The arrow keys move the selection, wrapping around the edges.
```js
document.addEventListener('keydown', (event) => {
const moves = { ArrowUp: [-1, 0], ArrowDown: [1, 0], ArrowLeft: [0, -1], ArrowRight: [0, 1] }
if (moves[event.key]) {
event.preventDefault()
const [dr, dc] = moves[event.key]
selected = { r: (selected.r + dr + 9) % 9, c: (selected.c + dc + 9) % 9 }
}
})
```moves is a table from key name to a row and column change.preventDefault stops the arrows from scrolling the page.(selected.r + dr + 9) % 9 wraps: from row 0 going up gives row 8.Above the pointerdown listener, write the keydown listener.
Skills: Keyboard and mouse input
← Click to select Write digits →