Created
December 3, 2013 18:04
-
-
Save enopanen/7774263 to your computer and use it in GitHub Desktop.
Dealing with user input is another grey area I have come across. The jQuery keydown and keyup event listeners are perfect for dealing with such experiences. Both of these methods are called at very different times during the keystroke event. So make sure you have the application planned out before deciding which one to use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('input').keydown(function(e) { | |
// variable e contains keystroke data | |
// only accessible with .keydown() | |
if(e.which == 11) { | |
e.preventDefault(); | |
} | |
}); | |
$('input').keyup(function(event) { | |
// run other event codes here | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment