Skip to main content
August 21, 2012
Answered

Switch Focus to Captivate in Beginning

  • August 21, 2012
  • 1 reply
  • 433 views

I want to disable the arrow keys so that the page does not scroll when the Captivate movie plays.

One of my simulations requires the use of UP and DOWN arrow keys.  When they are pressed, the entire browser window scrolls.  I don't want this.

I found this code on the Internet and added it to the Web page that has the embedded swf file.

<script type="text/javascript">

var keys = [];
window.addEventListener("keydown",
    function(e){
        keys[e.keyCode] = true;
        switch(e.keyCode){
            case 37: case 39: case 38:  case 40: // Arrow keys
            case 32: e.preventDefault(); break; // Space
            default: break; // do not block other keys
        }
    },
false);
window.addEventListener('keyup',
    function(e){
        keys[e.keyCode] = false;
    },
false);

</script>

It works in Firefox when Captivate movie loads.  However, in IE, I have to press the TAB key in order to prevent the arrow keys from scrolling the entire page.  I don't want my students to have to press the TAB key.

I was wondering if there is a way to shift the focus to the Captivate movie when the movie loads?

Thanks

    This topic has been closed for replies.
    Correct answer

    I figured out a workaround to disable arrow keys from scrolling the page.  In addition to the above javascript code, I modified the body tag:

    <body onload="RightClick.init();" style="overflow: hidden>

    1 reply

    Correct answer
    August 22, 2012

    I figured out a workaround to disable arrow keys from scrolling the page.  In addition to the above javascript code, I modified the body tag:

    <body onload="RightClick.init();" style="overflow: hidden>