Class fever.app.accelerator.KeyboardController

Description

Implements key listening system.

2 ways are available to listen to keys event.

If using Event implementation, use addKeyListener and removeKeyListener methods to manage key listeners.

If using FrontController implementation, use push and remove methods to manage key Command listener.

Take a look at Keyboard class to see all Key constantdefinition. Defines keys sequence using KeyCombo class.

Note : Combo are not available with KeyUp listening system.

Example

	 var controller : KeyboardController = KeyboardController.getInstance();
	
	 //defines shortcut with FrontController behaviour
	 controller.push( Keyboard.onKeyA, new KeyACommand() );
	
	 //defines shortcut using event listening
	 controller.addKeyListener(Keyboard.onKeyV, this, _onKeyV);
	
	 //defines a combo
	 //Note : Name (Ctrl+T) must be logic, it's used for accessibility shortcut definiton
	 controller.push( new KeyCombo( Keyboard.onKeyCONTROL, Keyboard.onKeyT ), new KeyComboCommand() );
	 
	 //simulate shortcut activation
	 controller.broadcastEvent( Keyboard.onKeyG );
 

See Also

Field Index

keyDown, keyUp

Method Index

addKeyListener(), clean(), fire(), getInstance(), push(), remove(), removeKeyListener(), toString()

Field Detail

keyDown

static public keyDown:Boolean
Defines if we listen to KeyDown event or not.

keyUp

static public keyUp:Boolean
Defines if we listen to KeyUp event or not.

Note that Combo are not available with KeyUp system.

Method Detail

getInstance

static public function getInstance():KeyboardController

Creates and returns KeyboardController instance.

Always return same instance.

Return

KeyboardController instance

clean

static public function clean():Void

Force keydown list cleaning.

Really useful, for example, when a context dialog box open. Either Flash player doesn't know about 'KeyUp' state.

fire

public function fire(keyEvent:Keyboard):Void

Broadcasts specific key event.

Parameters

keyEventKeyboard key structure name

push

public function push(k:KeyDefinition, c:Command):Void

Adds new command definition.

Parameters

kKeyboard or KeyCombo instance
cCommand instance

remove

public function remove(k:KeyDefinition):Void

Removes command definition.

Parameters

kKeyboard or KeyCombo instance

addKeyListener

public function addKeyListener(type:KeyDefinition, listener):Void

Adds passed-in listener for receiving passed-in event type.

Parameters

typeKeyboard or KeyCombo instance
listenerListener object.

removeKeyListener

public function removeKeyListener(type:KeyDefinition, listener):Void

Removes passed-in listener that suscribed for passed-in type event.

Parameters

typeKeyboard or KeyCombo instance
listenerListener object.

toString

public function toString():String

KeyboardController instance stringifier.

Return

KeyboardController string representation.