Invoking a function with the ESC key in fullscreen mode

Hi, I have a movie with a video and when I exit fullscreen mode (pressing ESC) I want to execute a function. I mean, exit fullscreen and execute my function at the same time when pressing ‘ESC’

I tried to add a listener but it doesnt work…

listener = new Object();
listener.onKeyDown = 
    function() {
        if (Key.isDown(Key.ESCAPE)) {myFunction() };
    };
Key.addListener(listener);

When I go fullscreen, I press ESC and flash exits fullscreen, but myFunction() doesnt load. If I press ESC a second time myFunction() works.

Is the ESC key blocked in fullscreen mode?

Yes.

You could try adding a listener to detect when they’ve exited Fullscreen:

EventListener = new Object();
EventListener.onFullScreen = function(bFull:Boolean) {
 // change to fullscreen mode has been detected
 if (!bFull) {
  // call your function here
 }
};
Stage.addListener(EventListener);

Thanx glosrfc :wink: