# Keyboard Event Listener being interrupted

**URL:** <https://forum.kirupa.com/t/keyboard-event-listener-being-interrupted/308240>\
**Category:** flash\
**Created:** [April 20, 2010, 1:17am UTC](https://forum.kirupa.com/t/keyboard-event-listener-being-interrupted/308240 "2010-04-20T01:17:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zholen](https://avatars.discourse-cdn.com/v4/letter/z/3bc359/32.png) [@Zholen](https://forum.kirupa.com/u/Zholen)\
**Post date:** [April 20, 2010, 1:17am UTC](https://forum.kirupa.com/t/keyboard-event-listener-being-interrupted/308240/1 "2010-04-20T01:17:18Z")

</div>

So I am making a tower defense game that has a unit that acts as a mobile tower. My other towers also have a Sell feature. When I sell a tower it seems to be interrupting my Keyboard listners and this causes my mobile tower either no be moveable or he runs off screen. I have a key class that handles my Keyboard listeners and a function (isDown) that checks if the key is down from an array. Anyway when I sell a tower I perform a removeChild(t) from my movie clip that handles all of my towers and this causes my keyboard listeners to malfunction. Could anyone explain why?

// Let’s clean up dead Towers  
for (var i:int = 0; i \< this.mTowers.length; i++)  
{  
var t:Tower = this.mTowers\*;  
if (t.IsDestroyed())  
{  
[//this.mTowerMC.removeChild](https://this.mTowerMC.removeChild)(t); \<–This line causes the issue.  
this.mTowers.splice(i, 1);  
}  
}

I forgot to mention that the Keylisteners are added within the fla and the mobile tower is not part of that mTowerMC movieclip.
