Skip to content

Instantly share code, notes, and snippets.

@sgreenfield
Created June 4, 2012 23:18
Show Gist options
  • Save sgreenfield/2871423 to your computer and use it in GitHub Desktop.
Save sgreenfield/2871423 to your computer and use it in GitHub Desktop.
jQuery keypress with intent to type a value
$(document).keypress(function(e) {
var code = (e.keyCode) ? e.keyCode : e.which, character;
if(e.charCode && code !== 32 && code !== 13 && !e.altKey && !e.ctrlKey && !e.metaKey){
character = String.fromCharCode(e.charCode);
console.log('value: ', character);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment