I have a form with a textfield inside and I am trying to disable the default behavior when the browser submits the whole form if the user presses Enter while the textfield is selected.
$('#recaptcha_response_field').keydown(function(event) { if (event.keyCode == 13) { event.preventDefault(); event.stopPropagation(); event.stopImmediatePropagation(); alert("You Press ENTER key"); return false; } }); Currently am getting "You Press ENTER key" and the default behavior isn't overridden.
keyupevent.preventDefaultis absolutely enough. Neither do you need to stop propagation, nor return false.