Workshop › Tic-tac-toe › Step 14 of 33
The player plays with the mouse. We ask the canvas to tell us about every click. As a first try, any click plays the middle cell and redraws.
```js
canvas.addEventListener('click', (event) => {
play(4)
draw()
})
```canvas.addEventListener('click', ...) runs the function each time the canvas is clicked.event carries information about the click (we use it in the next step).play(4) makes a move in cell 4, draw() shows the new board.Write the listener above function draw() {, under play, with empty lines around it. Run and click the board twice.
Skills: Keyboard and mouse input
← No playing on a taken cell Which cell was clicked? →