JSFiddle - React, Tailwind, and code Playground
by frogggeee McFrogggeee
HTML
<!DOCTYPE html>
<html>
<head>
<body>
<h1>click detector</h1>
<canvas id = "canvas" width = "350" height = "350" ></canvas>
<script>
window.onload = function() {
var theCanvas = document.getElementById("canvas");
var ctx = theCanvas.getContext("2d");
canvas.addEventListener('mousedown', onDown, false);
}
function onDown(event) {
cx = event.pageX;
cy = event.pageY;
alert (cx + ", " + cy);
}
</script>
</body>
</head>
</html>