Skip to content

Instantly share code, notes, and snippets.

@isner
Last active August 29, 2015 13:57
Show Gist options
  • Save isner/9553406 to your computer and use it in GitHub Desktop.
Save isner/9553406 to your computer and use it in GitHub Desktop.
inArray-like check for event.which
var which = event.which; // or whatever defines `which`
var chars = [1, 2, 3, 4];
if (iPressedOneOfThese(chars)) {
// Do my stuff
}
function iPressedOneOfThese(array) {
array.filter(chars, function (char) {
return which === char;
}).length
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment