# Key.removeListener Not Working

**URL:** <https://forum.kirupa.com/t/key-removelistener-not-working/296212>\
**Category:** flash\
**Created:** [September 10, 2009, 11:37pm UTC](https://forum.kirupa.com/t/key-removelistener-not-working/296212 "2009-09-10T23:37:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ventolinmono](https://avatars.discourse-cdn.com/v4/letter/v/4af34b/32.png) [@ventolinmono](https://forum.kirupa.com/u/ventolinmono)\
**Post date:** [September 10, 2009, 11:37pm UTC](https://forum.kirupa.com/t/key-removelistener-not-working/296212/1 "2009-09-10T23:37:35Z")

</div>

Hi

Having trouble removing listeners.  
I have a navigation between 2 scenes. Each scene has its own listener for different functions on same keys. The first play of each scene goes without problems. When i go back to the first scene the key.listener of scene 2 is active on this.  
I even added a null on the first scene to see if the keys are overwritten. But the keys behave as if i was on the second scene.

Thanks

```auto
/* Scene1 */
Key.removeListener(myListener2);
var myListener1:Object = new Object();
myListener1.onKeyDown = function() {
    if (Key.getCode() == Key.ENTER) { 
        gotoAndStop ("scene2", 1);
        }
        else if (Key.getCode() == Key.DOWN) { 
        null;
        }        
        else if (Key.getCode() == Key.UP) { 
        null;
        }
        else if (Key.getCode() == Key.RIGHT) { 
         gotoAndStop ("scene2, 1");
         }
};
Key.addListener(myListener1);
stop ();

/* Scene2 */
Key.removeListener(myListener1);
var myListener2:Object = new Object();
myListener2.onKeyDown = function() {
    if (Key.getCode() == Key.ENTER) { 
        gotoAndStop ("scene3", 1);
        }
        else if (Key.getCode() == Key.DOWN) { 
        gotoAndStop ("frame1");
        }        
        else if (Key.getCode() == Key.UP) { 
        gotoAndStop ("frame2");
        }
        else if (Key.getCode() == Key.LEFT) { 
        gotoAndStop ("scene1, 1");
        }
};
Key.addListener(myListener2);
stop ();

```
