function readMouseMove(e) { x = e.pageX - canvas.getBoundingClientRect().left y = e.pageY - canvas.getBoundingClientRect().top } document.onmousemove = readMouseMove if (ctx.isPointInPath(x, y)) { alert("HELLO!") }