I have the following jquery code in use to submit a form if the enter key is pressed:
$('body').on('keypress', 'input', function(event) {
if (event.which === 13) {
event.preventDefault();
$(this).closest('form').submit();
}
});
Also, I have my login page set up to .focus() on the username field on page load.
So if a user just holds on the 'enter' key, it will submit, fail, return, focus, submit, repeat.
I could put the keypress event to only trigger when in the password field, but I'd rather find a way to detect a long keypress or something to prevent this scenario.
Throttle the event so it can only happen once per second.