I drew a canvas, and then with the code
canvas.addEventListener(\"mousedown\", clicked(event), false);
I added an event listener to run clicked
canvas.addEventListener("mousedown", clicked,false);
You need to just pass the function reference and not actually call it like this:
canvas.addEventListener("mousedown", clicked, false);
Then, the function should be defined like this:
function clicked(event) {
// code here
}
When you include parens after the function name, it is immediately executed and it's return value is what is passed to addEventListener()
which is probably not what you wanted at all. Leave off the parens to just pass a function reference.