# Invoking a function with the ESC key in fullscreen mode

**URL:** <https://forum.kirupa.com/t/invoking-a-function-with-the-esc-key-in-fullscreen-mode/259957>\
**Category:** flash\
**Created:** [May 10, 2008, 10:23pm UTC](https://forum.kirupa.com/t/invoking-a-function-with-the-esc-key-in-fullscreen-mode/259957 "2008-05-10T22:23:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loyx](https://avatars.discourse-cdn.com/v4/letter/l/e274bd/32.png) [@Loyx](https://forum.kirupa.com/u/Loyx)\
**Post date:** [May 10, 2008, 10:23pm UTC](https://forum.kirupa.com/t/invoking-a-function-with-the-esc-key-in-fullscreen-mode/259957/1 "2008-05-10T22:23:19Z")

</div>

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…

```auto
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?

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [May 10, 2008, 10:29pm UTC](https://forum.kirupa.com/t/invoking-a-function-with-the-esc-key-in-fullscreen-mode/259957/2 "2008-05-10T22:29:11Z")

</div>

Yes.

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

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

```

---

<div class="post-metadata">

**Author:** ![Loyx](https://avatars.discourse-cdn.com/v4/letter/l/e274bd/32.png) [@Loyx](https://forum.kirupa.com/u/Loyx)\
**Post date:** [May 11, 2008, 2:51am UTC](https://forum.kirupa.com/t/invoking-a-function-with-the-esc-key-in-fullscreen-mode/259957/3 "2008-05-11T02:51:07Z")

</div>

Thanx glosrfc 😉
