1  /**
     2   * com.sekati.input.KeyManager
     3   * @version 1.0.5
     4   * @author jason m horwitz | sekati.com
     5   * Copyright (C) 2007  jason m horwitz, Sekat LLC. All Rights Reserved.
     6   * Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
     7   */
     8   
     9  //import com.sekati.events.Dispatcher;
    10  import com.sekati.log.Logger;
    11  import com.sekati.utils.Delegate;
    12  
    13  /**
    14   * Key Manager Class.
    15   */
    16  class com.sekati.input.KeyManager {
    17  
    18  	private static var _instance:KeyManager;
    19  	private static var _this:KeyManager;
    20  	private static var _key:Object;
    21  	private static var _keyDownEVENT:String = "onKeyDown";
    22  	private static var _keyUpEVENT:String = "onKeyUp";
    23  
    24  	/**
    25  	 * Singleton Private Constructor
    26  	 */
    27  	private function KeyManager() {
    28  		_this = this;
    29  		_key = new Object( );
    30  		_key.onKeyDown = Delegate.create( _this, onKeyDown );
    31  		Key.addListener( _key );
    32  	}
    33  
    34  	private function onKeyDown():Void {
    35  		//Dispatcher.$.dispatchEvent();	
    36  		Logger.$.status(_this, "KeyDown ::: ascii:" + Key.getAscii( ) + ", keycode:" + Key.getCode( ) );
    37  		if ((Key.getCode( ) == Key.LEFT) && (Key.getCode( ) == Key.getCode.UP)) {
    38  			//trace( "HOTKEY" );
    39  		}
    40  	}
    41  
    42  	private function onKeyUp():Void {
    43  		Logger.$.status(_this, "The ASCII code for the KeyUp is: " + Key.getAscii( ) );	
    44  	}
    45  
    46  	public function hotKey(k:Array):Boolean {
    47  		//if ((Key.isDown (Key.SHIFT) && Key.isDown (Key.RIGHT)) || (Key.isDown (Key.SHIFT) && Key.isDown (Key.LEFT)))
    48  		return false;
    49  	}
    50  
    51  	/**
    52  	 * Singleton Accessor
    53  	 * @return KeyManager
    54  	 */
    55  	public static function getInstance():KeyManager {
    56  		if (!_instance) {
    57  			_instance = new KeyManager( );
    58  		}
    59  		return _instance;
    60  	}
    61  
    62  	/**
    63  	 * Shorthand singleton accessor getter
    64  	 * @return KeyManager
    65  	 */
    66  	public static function get $():KeyManager {
    67  		return KeyManager.getInstance( );	
    68  	}		
    69  }