Packagecc.cote.feathers.softkeyboard
Classpublic class SoftKeyboard
InheritanceSoftKeyboard Inheritance feathers.core.FeathersControl

This class allows the creation of virtual on-screen keyboards. Various types of keyboard configurations are included in the package such as QWERTY, NUMPAD, etc. However, if a custom layout is needed, it is easy to create one by extending the Layout base class.

Creating a keyboard and listening for input is very easy. All you need to do is pass the desired layout to the SoftKeyboard constructor and add an event listener:

     var keyboard:SoftKeyboard = new SoftKeyboard(new QwertyEn());
     keyboard.addEventListener(SoftKeyboardEvent.KEY_UP, _onKeyUp);
     addChild(keyboard);

It is also possible to create keyboards with multiple layouts by passing a vector of Layout objects to the constructor. This makes it easy to have a keyboard with one layout for regular letters and another one for numbers and symbols, for example. Switching between them is possible by pressing the special SWITCH_LAYOUT key.

Layouts that have a SWITCH_LAYOUT key generally accept as a constructor parameter the class of the layout that the SWITCH_LAYOUT key should instantiate when pressed. Here is an example that will toggle between the QwertyEnSingleSwitch and NumbersAndSymbolsSingleSwitch layouts:

     var layouts:Vector.<Layout> = new <Layout>[
         new QwertyEnSingleSwitch(NumbersAndSymbolsSingleSwitch), 
         new NumbersAndSymbolsSingleSwitch(QwertyEnSingleSwitch)
     ];
     var keyboard:SoftKeyboard = new SoftKeyboard(layouts);
     addChild(keyboard);

A full, working code example is provided with the SoftKeyboard download package.

In order for the keyboard to display properly, you must skin it through the use of a Feathers' theme (a sample theme is provided in the download package). If you don't, a generic grey skin will be used for reference. Besides assigning skins in your theme, you should also define a TextRenderer and assign a TextFormat. For more information, see the Feathers documentation.

SoftKeyboard requires Feathers 1.0 or newer which itself requires the Starling framework.

See also

cc.cote.feathers.softkeyboard.layouts
cc.cote.feathers.softkeyboard.KeyEvent
http://cote.cc/projects/softkeyboard
http://feathersui.com/
http://gamua.com/starling/


Public Properties
 PropertyDefined By
  backgroundSkin : DisplayObject
The background to use for the SoftKeyboard.
SoftKeyboard
  capsLock : Boolean
Indicates whether the caps lock key is currently activated (true) or not (false).
SoftKeyboard
  layoutIndex : uint
The index of the currently displayed layout from the layouts vector.
SoftKeyboard
  layouts : Vector.<Layout>
[read-only] A vector of all Layout objects assigned to the keyboard.
SoftKeyboard
  padding : Number = 0
The free space between the outside of the keyboard and the keys.
SoftKeyboard
Public Methods
 MethodDefined By
  
SoftKeyboard(layouts:Object, width:Number = 320, height:Number = 160)
Creates a new SoftKeyboard object.
SoftKeyboard
Events
 Event Summary Defined By
  Dispatched when an on-screen key is pressed.SoftKeyboard
  Dispatched when an on-screen key is released.SoftKeyboard
Public Constants
 ConstantDefined By
  VERSION : String = 1.0a rev8
Version of this SoftKeyboard library
SoftKeyboard
Property Detail
backgroundSkinproperty
public var backgroundSkin:DisplayObject

The background to use for the SoftKeyboard.

capsLockproperty 
capsLock:Boolean

Indicates whether the caps lock key is currently activated (true) or not (false).


Implementation
    public function get capsLock():Boolean
    public function set capsLock(value:Boolean):void
layoutIndexproperty 
layoutIndex:uint

The index of the currently displayed layout from the layouts vector.


Implementation
    public function get layoutIndex():uint
    public function set layoutIndex(value:uint):void
layoutsproperty 
layouts:Vector.<Layout>  [read-only]

A vector of all Layout objects assigned to the keyboard.


Implementation
    public function get layouts():Vector.<Layout>
paddingproperty 
public var padding:Number = 0

The free space between the outside of the keyboard and the keys.

Constructor Detail
SoftKeyboard()Constructor
public function SoftKeyboard(layouts:Object, width:Number = 320, height:Number = 160)

Creates a new SoftKeyboard object.

Parameters
layouts:Object — A single Layout object or a vector of Layout objects to use with the keyboard
 
width:Number (default = 320) — Full outer width of the keyboard (including any padding)
 
height:Number (default = 160) — Full outer height of the keyboard (including any padding)

Throws
Error — First parameter must be a Layout object or a vector of Layout objects.

See also

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 an on-screen key is pressed.

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 an on-screen key is released. The release must be above the key that was initially pressed otherwise the event is not fired.

The KEY_UP constant defines the value of the type property of a keyUp event object.
Constant Detail
VERSIONConstant
public const VERSION:String = 1.0a rev8

Version of this SoftKeyboard library