Packagecom.desuade.utils
Classpublic class ShortcutManager
InheritanceShortcutManager Inheritance Object

Language Version : ActionScript 3
Since : 22.11.2009
Runtime Versions : AIR 1.0, Flash Player 9.0.0

Simple management of common key-based shortcuts



Public Properties
 PropertyDefined By
  currentCombo : Object = null
The current combo being pressed at the moment (null if no a combo isn't being pressed)
ShortcutManager
  currentKeys : Object
The current keys (keyCodes) that are being pressed
ShortcutManager
  expireTime : int = 3000
Time in ms to wait to expire key presses for keySequences
ShortcutManager
  keyCombos : Object
The object containing all the registered key combos
ShortcutManager
  keySequences : Object
The object containing all the registered key sequences
ShortcutManager
  pressedKeys : Array
An Array of keyCodes that have been pressed
ShortcutManager
  traceKeys : Boolean = false
Traces the keyCode everytime a key is pressed.
ShortcutManager
Public Methods
 MethodDefined By
  
ShortcutManager(target:Object)
This creates a new Shortcut object that will listen for keys pressed to perform a given method.
ShortcutManager
  
addKeyCombo(label:String, keys:Array, method:Function, hold:int = 0):void
This will add a shortcut that listens for keys that are being pressed at the same time, in no order.
ShortcutManager
  
addKeySequence(label:String, keys:Array, method:Function):void
This will add a shortcut that listens for keys that have been pressed only in the given order.
ShortcutManager
Protected Methods
 MethodDefined By
  
goCH(e:Object = null):void
ShortcutManager
Property Detail
currentComboproperty
public var currentCombo:Object = null

The current combo being pressed at the moment (null if no a combo isn't being pressed)

currentKeysproperty 
public var currentKeys:Object

The current keys (keyCodes) that are being pressed

expireTimeproperty 
public var expireTime:int = 3000

Time in ms to wait to expire key presses for keySequences

keyCombosproperty 
public var keyCombos:Object

The object containing all the registered key combos

keySequencesproperty 
public var keySequences:Object

The object containing all the registered key sequences

pressedKeysproperty 
public var pressedKeys:Array

An Array of keyCodes that have been pressed

traceKeysproperty 
public var traceKeys:Boolean = false

Traces the keyCode everytime a key is pressed. For debuging or learning the keyCode for keys

Constructor Detail
ShortcutManager()Constructor
public function ShortcutManager(target:Object)

This creates a new Shortcut object that will listen for keys pressed to perform a given method.

Parameters
target:Object — The target to listen to key presses from, usually: stage
Method Detail
addKeyCombo()method
public function addKeyCombo(label:String, keys:Array, method:Function, hold:int = 0):void

This will add a shortcut that listens for keys that are being pressed at the same time, in no order.

Parameters

label:String — The name of the shortcut
 
keys:Array — An Array of keyCodes to listen for
 
method:Function — The function to call when the shortcut is fired
 
hold:int (default = 0) — How long to hold keys down before it's registered

addKeySequence()method 
public function addKeySequence(label:String, keys:Array, method:Function):void

This will add a shortcut that listens for keys that have been pressed only in the given order.

Parameters

label:String — The name of the shortcut
 
keys:Array — An Array of keyCodes to listen for in the order to listen for
 
method:Function — The function to call when the shortcut is fired

goCH()method 
protected function goCH(e:Object = null):void

Parameters

e:Object (default = null)