Illustrates how to detect when and where a mouse button is pressed.
<html>
<head>
<title>mousedown</title>
<script>
function pressFn(e) {
// Note that "this" points to the HTML element
console.log("button",e.which,"loc",e.pageX-this.offsetLeft,e.pageY-this.offsetTop);
}
function setup() {
var canv = document.getElementById("canv");
canv.addEventListener("mousedown",pressFn);
}
</script>
</head>
<body onload="setup();">
<h3>Open the console to see output!</h3>
<canvas id="canv" width="300" height="200" style="border:1px gray solid;"></canvas>
</body>
</html>