<commit_before>package aerys.minko.type
{
	import flash.events.IEventDispatcher;
	import flash.events.KeyboardEvent;

	public final class KeyboardManager
	{
		private var _keys	: Array	= [];
		
		public function KeyboardManager()
		{
		}
		
		public function bind(dispatcher : IEventDispatcher) : void
		{
			dispatcher.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
			dispatcher.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
		}
		
		public function unbind(dispatcher : IEventDispatcher) : void
		{
			dispatcher.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
			dispatcher.removeEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
		}
		
		private function keyDownHandler(event : KeyboardEvent) : void
		{
			_keys[event.keyCode] = true;
		}
		
		private function keyUpHandler(event : KeyboardEvent) : void
		{
			_keys[event.keyCode] = false;
		}
		
		public function keyIsDown(keyCode : uint) : Boolean
		{
			return !!_keys[keyCode];
		}
	}
}<commit_msg>add (per key) up/down signals to KeyboardManager<commit_after>package aerys.minko.type
{
	import flash.events.IEventDispatcher;
	import flash.events.KeyboardEvent;

	public final class KeyboardManager
	{
		public static const NO_KEY	: uint		= uint(-1);
		
		private var _keys			: Array		= [];
		
		private var _downSignals	: Array		= [];
		private var _upSignals		: Array		= [];
		private var _keyDown		: Signal	= new Signal('KeyboardManager.keyDown');
		private var _keyUp			: Signal	= new Signal('KeyboardManager.keyDown');
		
		public function KeyboardManager()
		{
		}
		
		public function bind(dispatcher : IEventDispatcher) : void
		{
			dispatcher.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
			dispatcher.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
		}
		
		public function unbind(dispatcher : IEventDispatcher) : void
		{
			dispatcher.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
			dispatcher.removeEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
		}
		
		public function keyDown(keyCode : uint = 0xffffffff) : Signal
		{
			if (keyCode == NO_KEY)
				return _keyDown;
			else
				return _downSignals[keyCode] || (_downSignals[keyCode] = new Signal('KeyDown[' + keyCode + ']'));
		}
		
		public function keyUp(keyCode : uint = 0xffffffff) : Signal
		{
			if (keyCode == NO_KEY)
				return _keyUp;
			else
				return _upSignals[keyCode] || (_upSignals[keyCode] = new Signal('KeyUp[' + keyCode + ']'));
		}
		
		private function keyDownHandler(event : KeyboardEvent) : void
		{
			var keyCode : uint		= event.keyCode;
			var signal 	: Signal 	= _downSignals[keyCode] as Signal;
			
			_keys[keyCode] = true;
			
			if (signal != null)
				signal.execute(this, keyCode);
		}
		
		private function keyUpHandler(event : KeyboardEvent) : void
		{
			var keyCode : uint		= event.keyCode;
			var signal 	: Signal 	= _upSignals[keyCode] as Signal;
			
			_keys[keyCode] = false;
			
			if (signal != null)
				signal.execute(this, keyCode);
		}
		
		public function keyIsDown(keyCode : uint) : Boolean
		{
			return !!_keys[keyCode];
		}
	}
}
{'fraction_non_alphanumeric': 0.10360506658005846, 'fraction_numerical': 0.000974342318934719, 'mean_word_length': 3.820031298904538, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4426866', 'n_tokens_mistral': 1179, 'n_tokens_neox': 986, 'n_words': 210}