Be confused to event in JavaScript

Discussion in 'JavaScript' started by jason_steven, Jul 6, 2008.

  1. #1
    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!!
     
    jason_steven, Jul 6, 2008 IP
  2. bucabay

    bucabay Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Did you test this in different browsers with the same result?

    That definitely sounds buggy...
     
    bucabay, Jul 7, 2008 IP
  3. koolman

    koolman Peon

    Messages:
    76
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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"
     
    koolman, Jul 7, 2008 IP
  4. jason_steven

    jason_steven Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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!!!
     
    jason_steven, Jul 9, 2008 IP