Packagefeathers.utils.keyboard
Classpublic class KeyToState
InheritanceKeyToState Inheritance Object

Product Version : Feathers 3.2.0

Changes a target's state when a key is pressed or released on the keyboard. Conveniently handles all KeyboardEvent listeners automatically.

See also

feathers.utils.touch.TouchToState


Public Properties
 PropertyDefined By
  callback : Function
The function to call when the state is changed.
KeyToState
  cancelKeyCode : uint
The key that will cancel the state change if the key is down.
KeyToState
  currentState : String
[read-only] The current state of the utility.
KeyToState
  downState : String
The value for the "down" state.
KeyToState
  isEnabled : Boolean
May be set to false to disable state changes temporarily until set back to true.
KeyToState
  keyCode : uint
The key that will change the state of the target, when pressed.
KeyToState
  keyLocation : uint
The location of the key that will change the state, when pressed.
KeyToState
  target : IFocusDisplayObject
The target component that should change state when a key is pressed or released.
KeyToState
  upState : String
The value for the "up" state.
KeyToState
Public Methods
 MethodDefined By
  
KeyToState(target:IFocusDisplayObject = null, callback:Function = null)
Constructor.
KeyToState
Property Detail
callbackproperty
callback:Function

The function to call when the state is changed.

The callback is expected to have the following signature:

function(currentState:String):void


Implementation
    public function get callback():Function
    public function set callback(value:Function):void
cancelKeyCodeproperty 
cancelKeyCode:uint

The key that will cancel the state change if the key is down.

The default value is flash.ui.Keyboard.ESCAPE.


Implementation
    public function get cancelKeyCode():uint
    public function set cancelKeyCode(value:uint):void
currentStateproperty 
currentState:String  [read-only]

The current state of the utility. May be different than the state of the target.


Implementation
    public function get currentState():String
downStateproperty 
downState:String

The value for the "down" state.

The default value is feathers.controls.ButtonState.DOWN.


Implementation
    public function get downState():String
    public function set downState(value:String):void
isEnabledproperty 
isEnabled:Boolean

May be set to false to disable state changes temporarily until set back to true.


Implementation
    public function get isEnabled():Boolean
    public function set isEnabled(value:Boolean):void
keyCodeproperty 
keyCode:uint

The key that will change the state of the target, when pressed.

The default value is flash.ui.Keyboard.SPACE.


Implementation
    public function get keyCode():uint
    public function set keyCode(value:uint):void
keyLocationproperty 
keyLocation:uint

The location of the key that will change the state, when pressed. If uint.MAX_VALUE, then any key location is allowed.

The default value is uint.MAX_VALUE.


Implementation
    public function get keyLocation():uint
    public function set keyLocation(value:uint):void

See also

flash.ui.KeyLocation
targetproperty 
target:IFocusDisplayObject

The target component that should change state when a key is pressed or released.


Implementation
    public function get target():IFocusDisplayObject
    public function set target(value:IFocusDisplayObject):void
upStateproperty 
upState:String

The value for the "up" state.

The default value is feathers.controls.ButtonState.UP.


Implementation
    public function get upState():String
    public function set upState(value:String):void
Constructor Detail
KeyToState()Constructor
public function KeyToState(target:IFocusDisplayObject = null, callback:Function = null)

Constructor.

Parameters
target:IFocusDisplayObject (default = null)
 
callback:Function (default = null)