Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Location
    Now Southern Oregon. I was born and had lived my life in Los Angeles until relocating last year (2010)
    Posts
    215
    Thanks
    52
    Thanked 1 Time in 1 Post

    prevent arraw key scrolling in IE?

    I have an app that registers event handlers for keydown and looks for keyCode for arrow keys on keyboard. The problem is that the default action is to scroll the window if there is overflow. This is not necessary or useful in this application, and is a distraction.

    How do I use returnValue to prevent this default action?
    Or do I also need cancelBubble = true?

    Code:
                    else if(document.attachEvent)
                      {
                       document.attachEvent('onkeydown', function() { if(OBJ.gameOn) OBJ.keySwap(window.event, OBJ); });
                       window.event.returnValue = false; //// this does not seem to  do it.
                       window.event.cancelBubble = true; //// nor this
                      }
    Thank you for time and attention.

  • #2
    Regular Coder
    Join Date
    Aug 2010
    Location
    Now Southern Oregon. I was born and had lived my life in Los Angeles until relocating last year (2010)
    Posts
    215
    Thanks
    52
    Thanked 1 Time in 1 Post

    I got it....

    this works:
    Code:
             else if(document.attachEvent)
                      {
                       document.attachEvent('onkeydown', function() { if(OBJ.gameOn) OBJ.keySwap(window.event, OBJ); window.event.cancelBubble = true; window.event.returnValue = false;} );
                      }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •