Packagecc.cote.feathers.softkeyboard
Classpublic class Key
InheritanceKey Inheritance feathers.core.FeathersControl

The Key class creates individual soft-keyboard keys to use in keyboard Layouts and key collections.

Both the key and its label have several tokens in their nameList property to facilitate skinning of individual keys. First, they have a charCodeXX token where XX is the character code. Second, their label's text is also a token in their nameList. Finally, when appropriate, they will have the hasVariant token in their nameList to identify keys with variants.

See also

cc.cote.feathers.softkeyboard.layouts
cc.cote.feathers.softkeyboard.keycollections


Public Properties
 PropertyDefined By
  character : String
[read-only] The single character associated to the key.
Key
  charCode : uint
[read-only] The character code of the key.
Key
  hasVariants : Boolean
[read-only] Indicates whether the key is a variant key (true) or a primary key (false)
Key
  hasVariantsKeyDownSkin : DisplayObject
The skin to use for keys that have variants, in the 'hover' state.
Key
  hasVariantsKeyHoverSkin : DisplayObject
The skin to use for keys that have variants, in the 'hover' state.
Key
  hasVariantsKeyUpSkin : DisplayObject
The skin to use for keys that have variants, the 'up' state.
Key
  icon : DisplayObject
The key's icon (if any).
Key
  isPrintable : Boolean
[read-only] Indicates if the key is associated with a printable character.
Key
  isSelected : Boolean
Indicates if the key is 'selected'.
Key
  isSpecial : Boolean
[read-only] Indicates if the key is 'special'.
Key
  isVariant : Boolean
Indicates whether the key is a variant key (true) or a primary key (false)
Key
  isVisible : Boolean
[read-only] Indicates if the key is associated with a visible character.
Key
  keyVariantsDelay : uint = 150
The number of milliseconds to wait after a key has been pressed before displaying the variants (if any are available).
Key
  label : Label
The Label object used by this key
Key
  regularKeyDownSkin : DisplayObject
The skin to use for regular keys in the 'down' state.
Key
  regularKeyHoverSkin : DisplayObject
The skin to use for regular keys in the 'hover' state.
Key
  regularKeyUpSkin : DisplayObject
The skin to use for regular keys in the 'up' state.
Key
  relativeHeight : Number
[read-only] Relative height of the key expressed as a ratio of the default key height.
Key
  relativeWidth : Number
[read-only] Relative width of the key expressed as a ratio of the default key width.
Key
  selectedIcon : DisplayObject
The key's icon while in 'selected' state.
Key
  specialKeyDownSkin : DisplayObject
The skin to use for special keys in the 'down' state.
Key
  specialKeyHoverSkin : DisplayObject
The skin to use for special keys in the 'hover' state.
Key
  specialKeyUpSkin : DisplayObject
The skin to use for special keys in the 'up' state.
Key
  switchToLayoutClass : Class
A layout (specified by its class) to switch to when the key is released.
Key
  type : String
[read-only] The type of key (character, navigation, modifier, etc.).
Key
  variants : Vector.<Key>
[read-only] Vector of keys accessible by pressing and holding the key.
Key
  variantsContainer : Sprite
[read-only]
Key
Public Methods
 MethodDefined By
  
Key(charCode:int, variants:Vector.<Key> = null, type:String = characterKey, label:String = null, relativeWidth:Number = 1, relativeHeight:Number = 1, switchToLayoutClass:Class = null)
Creates a new instance of the Key object.
Key
  
changeCase(keyCase:String):void
Changes the case of the character, label and variants of the key.
Key
  
changeState(state:String):void
Changes the key's current state (which in turn will likely change its skin).
Key
  
dispose():void
[override]
Key
  
lowercase():void
Lowercases the character, label and variants of the key.
Key
  
uppercase():void
Uppercases the character, label and variants of the key.
Key
Events
 Event Summary Defined By
  Dispatched when a key is pressed down.Key
  Dispatched when a the key is released.Key
  Dispatched when the variants for a key should be displayed.Key
Public Constants
 ConstantDefined By
  AVAILABLE_STATES : Array
Array of valid key states
Key
  CHARACTER_KEY : String = characterKey
[static] An identifier for regular alphanumeric character keys.
Key
  DOWN_STATE : String = Down
[static] Constant associated with the text representation of the key down state
Key
  EDITING_KEY : String = editingKey
[static] An identifier for editing keys.
Key
  FUNCTION_KEY : String = functionKey
[static] An identifier for function keys.
Key
  HOVER_STATE : String = Hover
[static] Constant associated with the text representation of the key hover state
Key
  LOCK_KEY : String = lockKey
[static] An identifier for lock keys.
Key
  MODIFIER_KEY : String = modifierKey
[static] An identifier for modifier keys.
Key
  NAVIGATION_KEY : String = navigationKey
[static] An identifier for navigation keys.
Key
  NUMERIC_KEYPAD_KEY : String = numericKeypadKey
[static] An identifier for numeric keypad keys.
Key
  SOFTKEYBOARD_KEY_LABEL : String = softkeyboard-key-label
[static] Constant associated with the text representation of the label's name as used in the label's nameList property (for theming purposes).
Key
  SYSTEM_KEY : String = systemKey
[static] An identifier for system keys.
Key
  UP_STATE : String = Up
[static] Constant associated with the text representation of the key up state
Key
Property Detail
characterproperty
character:String  [read-only]

The single character associated to the key.


Implementation
    public function get character():String
charCodeproperty 
charCode:uint  [read-only]

The character code of the key.


Implementation
    public function get charCode():uint
hasVariantsproperty 
hasVariants:Boolean  [read-only]

Indicates whether the key is a variant key (true) or a primary key (false)


Implementation
    public function get hasVariants():Boolean
hasVariantsKeyDownSkinproperty 
public var hasVariantsKeyDownSkin:DisplayObject

The skin to use for keys that have variants, in the 'hover' state.

hasVariantsKeyHoverSkinproperty 
public var hasVariantsKeyHoverSkin:DisplayObject

The skin to use for keys that have variants, in the 'hover' state.

hasVariantsKeyUpSkinproperty 
public var hasVariantsKeyUpSkin:DisplayObject

The skin to use for keys that have variants, the 'up' state.

iconproperty 
public var icon:DisplayObject

The key's icon (if any). Icons are usually reserved for 'special' keys such as: CAPS_LOCK, ENTER, TAB, etc.

isPrintableproperty 
isPrintable:Boolean  [read-only]

Indicates if the key is associated with a printable character. Printable characters include all letters, numbers and symbols as well as the ENTER, SPACE and TAB keys.


Implementation
    public function get isPrintable():Boolean
isSelectedproperty 
isSelected:Boolean

Indicates if the key is 'selected'. The selected state is currently only used for the CAPS_LOCK key. When the CAPS_LOCK is engaged, a different icon is shown.


Implementation
    public function get isSelected():Boolean
    public function set isSelected(value:Boolean):void
isSpecialproperty 
isSpecial:Boolean  [read-only]

Indicates if the key is 'special'. A 'special' key is any key that is not a regular alpha-numeric character or the space character key.


Implementation
    public function get isSpecial():Boolean
isVariantproperty 
isVariant:Boolean

Indicates whether the key is a variant key (true) or a primary key (false)


Implementation
    public function get isVariant():Boolean
    public function set isVariant(value:Boolean):void
isVisibleproperty 
isVisible:Boolean  [read-only]

Indicates if the key is associated with a visible character. Visible characters include all letters, numbers and symbols.


Implementation
    public function get isVisible():Boolean
keyVariantsDelayproperty 
public var keyVariantsDelay:uint = 150

The number of milliseconds to wait after a key has been pressed before displaying the variants (if any are available).

labelproperty 
label:Label

The Label object used by this key


Implementation
    public function get label():Label
    public function set label(value:Label):void
regularKeyDownSkinproperty 
public var regularKeyDownSkin:DisplayObject

The skin to use for regular keys in the 'down' state.

regularKeyHoverSkinproperty 
public var regularKeyHoverSkin:DisplayObject

The skin to use for regular keys in the 'hover' state.

regularKeyUpSkinproperty 
public var regularKeyUpSkin:DisplayObject

The skin to use for regular keys in the 'up' state.

relativeHeightproperty 
relativeHeight:Number  [read-only]

Relative height of the key expressed as a ratio of the default key height.


Implementation
    public function get relativeHeight():Number
relativeWidthproperty 
relativeWidth:Number  [read-only]

Relative width of the key expressed as a ratio of the default key width.


Implementation
    public function get relativeWidth():Number
selectedIconproperty 
public var selectedIcon:DisplayObject

The key's icon while in 'selected' state.

specialKeyDownSkinproperty 
public var specialKeyDownSkin:DisplayObject

The skin to use for special keys in the 'down' state.

specialKeyHoverSkinproperty 
public var specialKeyHoverSkin:DisplayObject

The skin to use for special keys in the 'hover' state.

specialKeyUpSkinproperty 
public var specialKeyUpSkin:DisplayObject

The skin to use for special keys in the 'up' state.

switchToLayoutClassproperty 
public var switchToLayoutClass:Class

A layout (specified by its class) to switch to when the key is released. It is mostly used with the SWITCH_LAYOUT key but also works with other keys.

typeproperty 
type:String  [read-only]

The type of key (character, navigation, modifier, etc.).


Implementation
    public function get type():String
variantsproperty 
variants:Vector.<Key>  [read-only]

Vector of keys accessible by pressing and holding the key.


Implementation
    public function get variants():Vector.<Key>
variantsContainerproperty 
variantsContainer:Sprite  [read-only]


Implementation
    public function get variantsContainer():Sprite
Constructor Detail
Key()Constructor
public function Key(charCode:int, variants:Vector.<Key> = null, type:String = characterKey, label:String = null, relativeWidth:Number = 1, relativeHeight:Number = 1, switchToLayoutClass:Class = null)

Creates a new instance of the Key object.

Parameters
charCode:int — Character-code to assign to the key.
 
variants:Vector.<Key> (default = null) — A vector of Keys to use as variations of the main key. The key variants are displayed when the user keeps its finger for a little while on a key. For example, variants of the 'e' key could be 'é', 'è', 'ë', etc.
 
type:String (default = characterKey) — The type of key (CHARACTER_KEY, SYSTEM_KEY, etc.).
 
label:String (default = null) — The textual label to display on the key.
 
relativeWidth:Number (default = 1) — A ratio of the normal key width used to relatively enlarge or make a key smaller. For example, if you wanted a key to be twice as wide as usual, you would specify a relative width of 2.
 
relativeHeight:Number (default = 1) — A ratio of the normal key height used to enlarge or make a key smaller. For example, if you wanted a key to be twice as high as usual, you would specify a relative height of 2.
 
switchToLayoutClass:Class (default = null) — A layout (specified by its class) to switch to when the key is released. Only works with SoftKeyboard.SWITCH_LAYOUT keys.
Method Detail
changeCase()method
public function changeCase(keyCase:String):void

Changes the case of the character, label and variants of the key. This only affects keys whose isVisible property return true.

Parameters

keyCase:String — Desired case: TypographicCase.UPPERCASE or TypographicCase.LOWERCASE.

changeState()method 
public function changeState(state:String):void

Changes the key's current state (which in turn will likely change its skin).

Parameters

state:String — The state to change to. Allowed states are defined in the AVAILABLE_STATES constant array.

dispose()method 
override public function dispose():void

lowercase()method 
public function lowercase():void

Lowercases the character, label and variants of the key. This only affects keys whose isVisible property return true.

uppercase()method 
public function uppercase():void

Uppercases the character, label and variants of the key. This only affects keys whose isVisible property return true.

Event Detail
cc.cote.feathers.softkeyboard.KeyEvent.keyDown Event
Event Object Type: cc.cote.feathers.softkeyboard.KeyEvent
KeyEvent.type property = cc.cote.feathers.softkeyboard.KeyEvent.KEY_DOWN

Dispatched when a key is pressed down.

The KEY_DOWN constant defines the value of the type property of a keyDown event object.
cc.cote.feathers.softkeyboard.KeyEvent.keyUp Event  
Event Object Type: cc.cote.feathers.softkeyboard.KeyEvent
KeyEvent.type property = cc.cote.feathers.softkeyboard.KeyEvent.KEY_UP

Dispatched when a the key is released. The release position must be above the key that was initially pressed down otherwise the event is not fired. This allows the user to cancel the keyUp event.

The KEY_UP constant defines the value of the type property of a keyUp event object.
cc.cote.feathers.softkeyboard.KeyEvent.showVariants Event  
Event Object Type: cc.cote.feathers.softkeyboard.KeyEvent
KeyEvent.type property = cc.cote.feathers.softkeyboard.KeyEvent.SHOW_VARIANTS

Dispatched when the variants for a key should be displayed.

The SHOW_VARIANTS constant defines the value of the type property of a showVariants event object.
Constant Detail
AVAILABLE_STATESConstant
public const AVAILABLE_STATES:Array

Array of valid key states

CHARACTER_KEYConstant 
public static const CHARACTER_KEY:String = characterKey

An identifier for regular alphanumeric character keys.

DOWN_STATEConstant 
public static const DOWN_STATE:String = Down

Constant associated with the text representation of the key down state

EDITING_KEYConstant 
public static const EDITING_KEY:String = editingKey

An identifier for editing keys.

FUNCTION_KEYConstant 
public static const FUNCTION_KEY:String = functionKey

An identifier for function keys.

HOVER_STATEConstant 
public static const HOVER_STATE:String = Hover

Constant associated with the text representation of the key hover state

LOCK_KEYConstant 
public static const LOCK_KEY:String = lockKey

An identifier for lock keys.

MODIFIER_KEYConstant 
public static const MODIFIER_KEY:String = modifierKey

An identifier for modifier keys.

NAVIGATION_KEYConstant 
public static const NAVIGATION_KEY:String = navigationKey

An identifier for navigation keys.

NUMERIC_KEYPAD_KEYConstant 
public static const NUMERIC_KEYPAD_KEY:String = numericKeypadKey

An identifier for numeric keypad keys.

SOFTKEYBOARD_KEY_LABELConstant 
public static const SOFTKEYBOARD_KEY_LABEL:String = softkeyboard-key-label

Constant associated with the text representation of the label's name as used in the label's nameList property (for theming purposes).

SYSTEM_KEYConstant 
public static const SYSTEM_KEY:String = systemKey

An identifier for system keys.

UP_STATEConstant 
public static const UP_STATE:String = Up

Constant associated with the text representation of the key up state