Packageorg.aswing
Classpublic class KeyboardManager
InheritanceKeyboardManager Inheritance flash.events.EventDispatcher

KeyboardController controlls the key map for the action firing.

Thanks Romain for his Fever{

See also

org.aswing.KeyMap
org.aswing.KeyType


Protected Properties
 PropertyDefined by
  defaultMnemonicModifier : Array
[static]
KeyboardManager
  enabled : Boolean
KeyboardManager
  inited : Boolean
KeyboardManager
  keyJustActed : Boolean
KeyboardManager
  keymap : KeyMap
KeyboardManager
  keySequence : Vector
KeyboardManager
  mnemonicModifier : Array
KeyboardManager
Public Methods
 MethodDefined by
  
Singleton class, Don't create instance directly, in stead you should call getInstance().
KeyboardManager
  
[static]
KeyboardManager
  
KeyboardManager
  
KeyboardManager
  
init(root:DisplayObjectContainer):void
Init the keyboad manager, it will only start works when it is inited.
KeyboardManager
  
isEnabled():Boolean
KeyboardManager
  
isKeyDown(keyCode:uint):Boolean
Returns whether or not the key is down.
KeyboardManager
  
isKeyJustActed():Boolean
Returns whether or not just a key action acted when the last key down.
KeyboardManager
  
Returns whether or not the mnemonic modifier keys is down.
KeyboardManager
  
registerKeyAction(key:KeyType, action:Function):void
Registers a key action to the default key map of this controller.
KeyboardManager
  
setDefaultMnemonicModifier(keyCodes:Array):void
[static]
KeyboardManager
  
setEnabled(b:Boolean):void
KeyboardManager
  
setMnemonicModifier(keyCodes:Array):void
Sets the mnemonic modifier key codes, the default is [Ctrl, Shift], however for normal UI frameworks, it is [Alt], but because the flashplayer or explorer will eat [Alt] for thier own mnemonic modifier, so we set our default to [Ctrl, Shift].
KeyboardManager
  
Unregisters a key action to the default key map of this controller.
KeyboardManager
Events
 EventSummaryDefined by
   Dispatched when key is down.KeyboardManager
   Dispatched when key is up.KeyboardManager
Property detail
defaultMnemonicModifierproperty
protected static var defaultMnemonicModifier:Array
enabledproperty 
protected var enabled:Boolean
initedproperty 
protected var inited:Boolean
keyJustActedproperty 
protected var keyJustActed:Boolean
keymapproperty 
protected var keymap:KeyMap
keySequenceproperty 
protected var keySequence:Vector
mnemonicModifierproperty 
protected var mnemonicModifier:Array
Constructor detail
KeyboardManager()constructor
public function KeyboardManager()

Singleton class, Don't create instance directly, in stead you should call getInstance().

Method detail
getDefaultMnemonicModifier()method
public static function getDefaultMnemonicModifier():Array

Returns
Array
getKeyMap()method 
public function getKeyMap():KeyMap

Returns
KeyMap
getMnemonicModifier()method 
public function getMnemonicModifier():Array

Returns
Array
init()method 
public function init(root:DisplayObjectContainer):void

Init the keyboad manager, it will only start works when it is inited.

Parameters
root:DisplayObjectContainer — the key trigger root of this keyboard manager.

Throws
— if it is already inited.
isEnabled()method 
public function isEnabled():Boolean

Returns
Boolean
isKeyDown()method 
public function isKeyDown(keyCode:uint):Boolean

Returns whether or not the key is down.

Parameters
keyCode:uint — key code

Returns
Boolean — true if the specified key is down, false if not.
isKeyJustActed()method 
public function isKeyJustActed():Boolean

Returns whether or not just a key action acted when the last key down.

Returns
Boolean — true if there's key actions acted at last key down, false not.
isMnemonicModifierDown()method 
public function isMnemonicModifierDown():Boolean

Returns whether or not the mnemonic modifier keys is down.

Returns
Boolean — whether or not the mnemonic modifier keys is down.
registerKeyAction()method 
public function registerKeyAction(key:KeyType, action:Function):void

Registers a key action to the default key map of this controller.

Parameters
key:KeyType — the key type
 
action:Function — the action

See also

setDefaultMnemonicModifier()method 
public static function setDefaultMnemonicModifier(keyCodes:Array):voidParameters
keyCodes:Array
setEnabled()method 
public function setEnabled(b:Boolean):voidParameters
b:Boolean
setMnemonicModifier()method 
public function setMnemonicModifier(keyCodes:Array):void

Sets the mnemonic modifier key codes, the default is [Ctrl, Shift], however for normal UI frameworks, it is [Alt], but because the flashplayer or explorer will eat [Alt] for thier own mnemonic modifier, so we set our default to [Ctrl, Shift].

Sets null to make it allways keep same to getDefaultMnemonicModifier

Parameters
keyCodes:Array — the array of key codes to be the mnemoic modifier.
unregisterKeyAction()method 
public function unregisterKeyAction(key:KeyType):void

Unregisters a key action to the default key map of this controller.

Parameters
key:KeyType — the key type

See also

Event detail
keyDownevent 
Event object type: flash.events.KeyboardEvent

Dispatched when key is down.

keyUpevent  
Event object type: flash.events.KeyboardEvent

Dispatched when key is up.