Don't laugh, after I just said how wonderful AS3 is, I ran into a problem. It's probably easy to fix though.

Okay, so I have dialogs, which you close by pressing a button. So, they just say
Code:
this.stage.addEventListener(KeyboardEvent.KEY_DOWN, this.keyDown);
Which is called after they have been parented.
Code:
private function keyDown(e:KeyboardEvent):void {
	this.stage.removeEventListener(KeyboardEvent.KEY_DOWN, this.keyDown);
	/* etc */
}
But, well, sometimes the game seems to randomly stops receiving key events, especially in the IDE player with 'disable keyboard shortcuts', but I've also seen it in the web plugin. I have to click on the game again so it receives events again, so it seems to have lost focus, but there is no reason for that.

I also have a Key class somewhere which mimics Key.isDown functionality, I doubt it has any influence but it looks like this :

Code:
package com.crossconscious {
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	
	/**
	* ...
	* @author Sven Magnus
	*/
	public class Key {
		
		public static var stage:Stage;
		private static var keys:Object = {};
		
		public static function init(stage:Stage):void {
			Key.stage = stage;
			Key.stage.addEventListener(KeyboardEvent.KEY_UP, Key.keyUp);
			Key.stage.addEventListener(KeyboardEvent.KEY_DOWN, Key.keyDown);
			Key.stage.addEventListener(Event.DEACTIVATE, Key.clearKeys);
		}
		
		private static function keyUp(e:KeyboardEvent):void {
			if (e.keyCode in Key.keys) {
				delete Key.keys[e.keyCode];
			}
		}
		
		private static function keyDown(e:KeyboardEvent):void {
			Key.keys[e.keyCode] = true;
		}
		
		public static function isDown(keyCode:int):Boolean {
			if (Key.keys[keyCode]) return true;
			return false;
		}
		
		private static function clearKeys(e:Event):void {
			Key.keys = [];
		}
		
	}
	
}

It's probably something very obvious, but I just don't know what it is. Any ideas?