I'm not sure that solves the problem, we may be talking about two 
different issues...

So when you call registerGlobalKeyHandler(), where do you do it and 
what are you listening to that it registers a key was pressed in 
different windows?

Because when I add the listener to stage, only the window that the 
key was pressed in responds to the listener, it is the stage for that 
specific window, not the entire app.


--- In [email protected], "Andrew Wetmore" <[EMAIL PROTECTED]> 
wrote:
>
> the way I deal with this is to use a switch statement on the 
currentState:
> 
> in init() I call registerGlobalKeyHandler()
> 
> which is
> 
> 
> private function registerGlobalKeyHandler(): void{
> 
>      stage.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
>   }
> 
> and has this event handler:
> 
> private function keyHandler(event:KeyboardEvent):void{
> 
>       //handle the Enter key
>       if (event.keyCode == 13){
> 
> switch (currentState){
> case 'login':
> if ( loginButton.enabled == true ){
> tryLogin();
> }
> break;
> case 'register':
> if (registerButton.enabled == true){
> tryRegister();
> }
> break;
> ...
>       }
>    }
> }
> 
> This gives me a lot of control over what function responds in each 
part of
> the application, and lets me govern a variety of keys in different 
ways
> depending on what page we're on.
> 
> You could dispense with the switch statement and have the key click 
work the
> same everywhere.
> 
> 
> 
> -- 
> Andrew Wetmore
> User Experience Director
> Open Learning Exchange - www.ole.org
> 978-319-7324
>


Reply via email to