Problem:
With jQuery, how do I find out which key was pressed when I bind to the keypress event?
Solution:
With jQuery, how do I find out which key was pressed when I bind to the keypress event?
$('#searchbox input').bind('keypress', function(e) {});
I want to trigger an submit when ENTER is pressed.Solution:
var code = e.keyCode || e.which;
if(code == 13) { //Enter keycode
//Do something
}
No comments:
Post a Comment