Skip to content

Instantly share code, notes, and snippets.

@lean8086
Created May 23, 2012 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lean8086/2775317 to your computer and use it in GitHub Desktop.
Save lean8086/2775317 to your computer and use it in GitHub Desktop.
Binds multiple events into one listener
function bind(listener, events, callback, useCapture) {
events.split(" ").forEach(function (ev) {
listener.addEventListener(ev, callback, useCapture);
});
}
// Example:
// bind(document, "mousedown mouseup keydown keyup", proccess);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment