I have this code
http://jsfiddle.net/2Gay9/3/
HTML
<form action="/" method="get" onsubmit="return false";>
test: <input type="text" value="">
<input type="submit" value="submit">
</form>
JS
jQuery('input').bind("keydown click", function(event){
console.log(event.type);
console.log(jQuery(this));
});
Try hit RETURN in input text and look console:
keydown
jQuery(input)
click
jQuery(input submit)
QUESTION: Why browser is triggering a ‘click’ event on submit button, instead of trigger a ‘submit’ event in the form? Is this a project flaw or a specification? How can I cancel second event WITHOUT cancel form submission?
Tks
UPDATE
In other words, I just need to diferenciate my event from browser event.
SOLVED!
If I cant stop click event on submit button, I can workarround only diferenciating browser from users click. To diferenciate
browsers clickfromusers clickI will use mousedown event instead of click event.Every time we hit RETURN in a input text, browser trigger click on first submit button in current form. But this don’t trigger mousedown event, “exclusive for humans” in this case.
Fixed version, that prints event once.
http://jsfiddle.net/2Gay9/6/