How do I get the coordinates of a mouse click on a canvas element? [duplicate]

What’s the simplest way to add a click event handler to a canvas element that will return the x and y coordinates of the click (relative to the canvas element)?

No legacy browser compatibility required, Safari, Opera and Firefox will do.

22 Answers
22

Leave a Comment