View Full Version : Be confused to event in JavaScript
jason_steven
Jul 6th 2008, 7:17 am
When I set event.returnValue to false or return false in the onkeydown event handler,the onkeypress event will be cancelled,which I can't understand.Anyone may explain it ?
Thank you very much!!
bucabay
Jul 7th 2008, 2:54 pm
Did you test this in different browsers with the same result?
That definitely sounds buggy...
koolman
Jul 7th 2008, 6:54 pm
May be keydown is the first part of keypress action. So if keydown is canceled the keypress will be canceled as well.
It would be something like "onclick" = "onmousedown" + "onmouseup"
jason_steven
Jul 9th 2008, 9:23 pm
Hi,Koolman.I don't think so!
But because onkeyup event isn't cancelled at all !
ms-help(When we press F1 on the HTML source view of vs2005,it will appears) says as follows:
onkeydown
Event Information
Bubbles Yes
Cancels Yes
To invoke Press any keyboard key.
Default action Returns a number specifying the keyCode of the key that was pressed.
----------------------------------------------------------------------------------------------
onkeypress
Event Information
Bubbles Yes
Cancels Yes
To invoke Press any alphanumeric keyboard key.
Default action Returns a number specifying the Unicode value of the key that was pressed.
--------------------------------------------------------------------------------------------------
onkeyup
Event Information
Bubbles Yes
Cancels No
To invoke Release any keyboard key.
Default action Returns a number specifying the keyCode of the key that was released.
-------------------------------------------------------------------------------------------------
May be keyup cannot be cancelled,so if keydown is cancelled keyup isn't cancelled yet?
--------------------------------------------------------------------------------------------------
Thank you for your reply!!!
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.