Skip to main content
CBecker
Inspiring
March 20, 2014
Question

Keyboard Even (key down) not working on Mac

  • March 20, 2014
  • 1 reply
  • 444 views

I have been using this AS3 code to detect keyboard arrow presses:

Global function keyDownHandler(event:KeyboardEvent):void {

    trace("keyDownHandler: " + event.keyCode);

    trace("ctrlKey: " + event.ctrlKey);

    trace("keyLocation: " + event.keyLocation);

    trace("shiftKey: " + event.shiftKey);

    trace("altKey: " + event.altKey);

   

    if(event.keyCode == 39 ) {

        nextFrame();

        //zoom_pics.nextFrame();

    } else if(event.keyCode == 37 ) {

        prevFrame();

        //zoom_pics.prevFrame();

    }

}

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);

My customer/client says that the navigation isn't working on their Mac. I've published the SWF with an HTML file. It works fine on my PC. Has anyone seen this also? Does anyone have a solution?

This topic has been closed for replies.

1 reply

robdillon
Participating Frequently
March 21, 2014

The browser window has to be in focus. Tell your user that they need to actually click on the browser window first, so that the keystrokes will be used by the browser.

Alternately, you can force the focus by starting your movie with something that the user has to click on to begin. This will bring the keyboard focus to the browser window.