Skip to content

Instantly share code, notes, and snippets.

@composite
Created December 14, 2012 00:15
Show Gist options
  • Select an option

  • Save composite/4281343 to your computer and use it in GitHub Desktop.

Select an option

Save composite/4281343 to your computer and use it in GitHub Desktop.
Prevent key for input - useful for keypress event; function based
function preventKey(){
var shift=[].shift,e=window.event;
if(isNaN(+arguments[0])) e=shift.call(arguments)||e;
for(var i=0,len=arguments.length;i<len;i++){if((e.which||e.keyCode)==arguments[i]) return false;}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment