Packagesekati.managers
Classpublic final class KeyManager

KeyManager provides an interface for the centralized registering and handling of KeyboardEvents via the direct coupling of Keyboard events to actions. Registered Key or Key-Combo's may be added in a repeatable or non-repeatable fashion.


Example
  import sekati.ui.Keyboard
  
  // create a response relationship between a key and method (non-repeatable):
  KeyManager.$.addKeyListener( handler, false, Keyboard.UP );
  
  // create a response between a key combo and a method (repeatable):
  KeyManager.$.addKeyListener( handler, true, Keyboard.CONTROL, Keyboard.LEFT );
  

See also

sekati.ui.Keyboard
flash.ui.Keyboard
http://livedocs.adobe.com/flex/3/langref/flash/ui/Keyboard.html


Public Properties
 PropertyDefined by
  $ : KeyManager
[static][read-only] Shorthand singleton accessor getter
KeyManager
  enabled : Boolean
Indicates whether the KeyManager is enabled (true) or disabled (false).
KeyManager
Public Methods
 MethodDefined by
  
KeyManager($:SingletonEnforcer = null)
KeyManager Singleton Constructor
KeyManager
  
addKeyListener(handler:Function, repeat:Boolean = false, ... keys):void
Add a key or key combo.
KeyManager
  
destroy():void
Destroy the KeyManager instance.
KeyManager
  
[static] Singleton Accessor
KeyManager
  
isDown(keyCode:uint):Boolean
Returns true or false if the key represented by the keyCode passed is being pressed
KeyManager
  
removeKeyListener(handler:Function):void
Remove a key or key combo.
KeyManager
  
reset():void
Reset the Key Combo and Map.
KeyManager
Protected Methods
 MethodDefined by
  
clearKeys(e:Event = null):void
Clear the keyMap.
KeyManager
  
keyCheck():void
Check the key press to see if it matches our handlers.
KeyManager
  
keyPressHandler(e:KeyboardEvent = null):void
Add the key to the keyMap.
KeyManager
  
keyReleaseHandler(e:KeyboardEvent = null):void
Remove the key from the keyMap.
KeyManager
Property detail
$property
$:KeyManager  [read-only]

Shorthand singleton accessor getter

Implementation
    public static function get $():KeyManager
enabledproperty 
enabled:Boolean  [read-write]

Indicates whether the KeyManager is enabled (true) or disabled (false).

Implementation
    public function get enabled():Boolean
    public function set enabled(value:Boolean):void
Constructor detail
KeyManager()constructor
public function KeyManager($:SingletonEnforcer = null)

KeyManager Singleton Constructor

Parameters
$:SingletonEnforcer (default = null) — SingletonEnforcer - internal to the AS file; the param prevents external instantiation without error.
Method detail
addKeyListener()method
public function addKeyListener(handler:Function, repeat:Boolean = false, ... keys):void

Add a key or key combo.

Parameters
handler:Function — the function to be fired upon a complete key match.
 
repeat:Boolean (default = false) — if true depressed key handler will fire repeatedly, if false key handler will fire only once per press.
 
... keys — array of keyCodes (uint's) which will trigger the handler.

Example
   KeyManager.$.addKeyListener( runProgram, false, KeyManager.$.CONTROL, KeyManager.$.ENTER );
   KeyManager.$.addKeyListener( copyText, true, KeyManager.$.CONTROL, KeyManager.$.C ); 
   

clearKeys()method 
protected function clearKeys(e:Event = null):void

Clear the keyMap.

Parameters
e:Event (default = null)
destroy()method 
public function destroy():void

Destroy the KeyManager instance.

getInstance()method 
public static function getInstance():KeyManager

Singleton Accessor

Returns
KeyManager — KeyManager
isDown()method 
public function isDown(keyCode:uint):Boolean

Returns true or false if the key represented by the keyCode passed is being pressed

Parameters
keyCode:uint

Returns
Boolean
keyCheck()method 
protected function keyCheck():void

Check the key press to see if it matches our handlers.

keyPressHandler()method 
protected function keyPressHandler(e:KeyboardEvent = null):void

Add the key to the keyMap.

Parameters
e:KeyboardEvent (default = null)
keyReleaseHandler()method 
protected function keyReleaseHandler(e:KeyboardEvent = null):void

Remove the key from the keyMap.

Parameters
e:KeyboardEvent (default = null)
removeKeyListener()method 
public function removeKeyListener(handler:Function):void

Remove a key or key combo.

Parameters
handler:Function — the function to be fired upon a complete key match.

Example
   KeyManager.$.removeKeyListener( runProgram );
   KeyManager.$.removeKeyListener( copyText ); 
   

reset()method 
public function reset():void

Reset the Key Combo and Map.