0 Replies Latest reply on Jun 13, 2008 11:36 AM by Xopods

    Listening for keyboard input globally

      I'm making games in Flex and some of them are mostly keyboard driven, so I need to listen globally for keystrokes. The documentation says to listen on the stage, but couldn't get it to work at first.

      Now I realise that the problem is that it only starts listening once the user clicks on some interactive component within the application. Even putting something like "this.setFocus()" in the same code block as the addEventListener call doesn't work.

      This makes sense, I guess, for security reasons... you don't want someone embedding a Flex app in a banner ad or something and hijacking the user's keystrokes against their will. It may be that my only solution is to have something like an opening screen that says "Click here to play!" or whatever, and go from there... but is there another way? Something you could put in the wrapper HTML page or something to put focus on the application from the beginning?