mouseover
event listener:
yourCanvasVariable.addEventListener(`mouseover`, startDrawing)Then check if the user is holding down the mouse by checking the MouseEvent buttons property:
function startDrawing(event) { // check if the left mouse button is pressed if (event.buttons == 1) { // your existing code here } }