I have a button and the following javascript routine.
$("button").keydown( function(key) {
switch(key.keyCode) {
case 32: //space
return false;
}
} );
as I understood it, the return false;
would stop the keypress from being processed. So $("button").click();
would not be called. For other keyCodes, this works as expected. For example, if I intercept40
, which is the down button, the page is not scrolling.
I noticed this behavior in Firefox.
Why does the return false;
does not stop the button click event on space? What does the javascript spec say about this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…