public static removeListener(listener:Object) : Boolean
Removes an object previously registered with Key.addListener().
listener:Object - An object.
Boolean - If the listener was successfully removed, the method returns true. If the listener was not successfully removed (for example, because the listener was not on the Key objects listener list), the method returns false.
The following example moves a movie clip called car_mc using the Left and Right arrow keys. The listener is removed when you press Escape, and car_mc no longer moves.
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
switch (Key.getCode()) {
case Key.LEFT :
car_mc._x -= 10;
break;
case Key.RIGHT :
car_mc._x += 10;
break;
case Key.ESCAPE :
Key.removeListener(keyListener);
}
};
Key.addListener(keyListener);