Skip to content

Instantly share code, notes, and snippets.

@ducdhm
Last active August 29, 2015 13:56
Show Gist options
  • Save ducdhm/9244391 to your computer and use it in GitHub Desktop.
Save ducdhm/9244391 to your computer and use it in GitHub Desktop.
Get value when press key down with keydown2
$('#query').keydown2(function () {
console.log($(this).val());
});
(function($) {
$.fn.keydown2 = function(callback) {
return $(this).each(function() {
var control = $(this);
control.keydown(function() {
setTimeout(function() {
callback.call(control, callback);
}, 0);
});
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment