Reputation: 6255
In my project, there is a button search which seems to be the default button to trigger when the ENTER key has been pressed.
How can I detect a keydown event with jQuery for a login button?
It's an ASP.NET project.
Upvotes: 0
Views: 1050
Reputation: 3914
Bind the "keypress" event handler to an element using jQuery.
See .keyPress() in the jQuery API.
Example code:
$('#login_button_id').keypress(function(event) {
//prevent submission when enter key pressed
if (event.keyCode == '13') {
event.preventDefault();
}
}
Upvotes: 2