Created
November 22, 2013 04:09
-
-
Save goliatone/7594727 to your computer and use it in GitHub Desktop.
keydown wrapper
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
(function($) { | |
$.fn.enterKey = function(key, handler) { | |
return this.keydown(function(ev) { | |
if (ev.which == key) | |
return handler.call(this, ev); | |
}); | |
}; | |
})(jQuery); | |
$('#test').enterKey(13, function(ev) { | |
console.log(ev) | |
alert('You hit enter after typing: ' + this.value); | |
}); | |
//<input id=test value="Hit enter in this textbox" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment