Skip to content

Instantly share code, notes, and snippets.

@jtenner
Last active December 28, 2015 17:09
var down = false;
canvas.addEventListener("mousedown", function (evt) { //event listener
down = onButton(getMousePos(evt));
});
//handle the document mouseup to reset the "down" variable every time.
document.addEventListener("mouseup", function (evt) {
if (onButton(getMousePos(evt)) && down) {
//we got a click!
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment