Getting the Mouse’s Position

Add input handlers on the canvas window

<script>
    function mousemove(event) {
        if (move) {
            mx = event.clientX;
            my = event.clientY;
        }
    }
</script>

<canvas id="canvas" width="800px" height="800px"
    onmousedown="move = true;"
    onmousemove="mousemove(event)"
    onmouseup="move = false;"
></canvas>