Package | starling.events |
Class | public class KeyboardEvent |
Inheritance | KeyboardEvent Event Object |
This is Starling's version of the Flash KeyboardEvent class. It contains the same properties as the Flash equivalent.
To be notified of keyboard events, add an event listener to any display object that is part of your display tree. Starling has no concept of a "Focus" like native Flash.
See also
Property | Defined By | ||
---|---|---|---|
altKey : Boolean [read-only] Indicates whether the Alt key is active on Windows or Linux;
indicates whether the Option key is active on Mac OS. | KeyboardEvent | ||
bubbles : Boolean [read-only] Indicates if event will bubble. | Event | ||
charCode : uint [read-only] Contains the character code of the key. | KeyboardEvent | ||
ctrlKey : Boolean [read-only] Indicates whether the Ctrl key is active on Windows or Linux;
indicates whether either the Ctrl or the Command key is active on Mac OS. | KeyboardEvent | ||
currentTarget : EventDispatcher [read-only] The object the event is currently bubbling at. | Event | ||
data : Object [read-only] Arbitrary data that is attached to the event. | Event | ||
keyCode : uint [read-only] The key code of the key. | KeyboardEvent | ||
keyLocation : uint [read-only] Indicates the location of the key on the keyboard. | KeyboardEvent | ||
shiftKey : Boolean [read-only] Indicates whether the Shift key modifier is active (true) or inactive (false). | KeyboardEvent | ||
target : EventDispatcher [read-only] The object that dispatched the event. | Event | ||
type : String [read-only] A string that identifies the event. | Event |
Method | Defined By | ||
---|---|---|---|
KeyboardEvent(type:String, charCode:uint = 0, keyCode:uint = 0, keyLocation:uint = 0, ctrlKey:Boolean = false, altKey:Boolean = false, shiftKey:Boolean = false) Creates a new KeyboardEvent. | KeyboardEvent | ||
isDefaultPrevented():Boolean Checks whether the preventDefault() method has been called on the event. | KeyboardEvent | ||
preventDefault():void Cancels the keyboard event's default behavior. | KeyboardEvent | ||
stopImmediatePropagation():void Prevents any other listeners from receiving the event. | Event | ||
stopPropagation():void Prevents listeners at the next bubble stage from receiving the event. | Event | ||
toString():String Returns a description of the event, containing type and bubble information. | Event |
Constant | Defined By | ||
---|---|---|---|
ADDED : String = added [static] Event type for a display object that is added to a parent. | Event | ||
ADDED_TO_STAGE : String = addedToStage [static] Event type for a display object that is added to the stage | Event | ||
CANCEL : String = cancel [static] An event type to be utilized in custom events. | Event | ||
CHANGE : String = change [static] An event type to be utilized in custom events. | Event | ||
CLOSE : String = close [static] An event type to be utilized in custom events. | Event | ||
COMPLETE : String = complete [static] Event type that may be used whenever something finishes. | Event | ||
CONTEXT3D_CREATE : String = context3DCreate [static] Event type for a (re)created stage3D rendering context. | Event | ||
ENTER_FRAME : String = enterFrame [static] Event type for a display object that is entering a new frame. | Event | ||
FATAL_ERROR : String = fatalError [static] Event type that is dispatched by the Starling instance when it encounters a problem
from which it cannot recover, e.g. | Event | ||
IO_ERROR : String = ioError [static] Event type that is dispatched by the AssetManager when a file/url cannot be loaded. | Event | ||
KEY_DOWN : String = keyDown [static] Event type for a key that was pressed. | KeyboardEvent | ||
KEY_UP : String = keyUp [static] Event type for a key that was released. | KeyboardEvent | ||
OPEN : String = open [static] An event type to be utilized in custom events. | Event | ||
PARSE_ERROR : String = parseError [static] Event type that is dispatched by the AssetManager when an xml or json file couldn't
be parsed. | Event | ||
READY : String = ready [static] An event type to be utilized in custom events. | Event | ||
REMOVED : String = removed [static] Event type for a display object that is removed from its parent. | Event | ||
REMOVED_FROM_STAGE : String = removedFromStage [static] Event type for a display object that is removed from the stage. | Event | ||
REMOVE_FROM_JUGGLER : String = removeFromJuggler [static] Event type for an animated object that requests to be removed from the juggler. | Event | ||
RENDER : String = render [static] Event type that is dispatched by the Starling instance directly before rendering. | Event | ||
RESIZE : String = resize [static] Event type for a resized Flash Player. | Event | ||
ROOT_CREATED : String = rootCreated [static] Event type that indicates that the root DisplayObject has been created. | Event | ||
SCROLL : String = scroll [static] An event type to be utilized in custom events. | Event | ||
SECURITY_ERROR : String = securityError [static] Event type that is dispatched by the AssetManager when a file/url cannot be loaded. | Event | ||
SELECT : String = select [static] An event type to be utilized in custom events. | Event | ||
SKIP_FRAME : String = skipFrame [static] Event type for a frame that is skipped because the display list did not change. | Event | ||
TEXTURES_RESTORED : String = texturesRestored [static] Event type that is dispatched by the AssetManager after a context loss. | Event | ||
TRIGGERED : String = triggered [static] Event type for a triggered button. | Event | ||
UPDATE : String = update [static] An event type to be utilized in custom events. | Event |
altKey | property |
altKey:Boolean
[read-only] Indicates whether the Alt key is active on Windows or Linux; indicates whether the Option key is active on Mac OS.
public function get altKey():Boolean
charCode | property |
charCode:uint
[read-only] Contains the character code of the key.
public function get charCode():uint
ctrlKey | property |
ctrlKey:Boolean
[read-only] Indicates whether the Ctrl key is active on Windows or Linux; indicates whether either the Ctrl or the Command key is active on Mac OS.
public function get ctrlKey():Boolean
keyCode | property |
keyCode:uint
[read-only] The key code of the key.
public function get keyCode():uint
keyLocation | property |
keyLocation:uint
[read-only] Indicates the location of the key on the keyboard. This is useful for differentiating keys that appear more than once on a keyboard.
public function get keyLocation():uint
See also
shiftKey | property |
shiftKey:Boolean
[read-only] Indicates whether the Shift key modifier is active (true) or inactive (false).
public function get shiftKey():Boolean
KeyboardEvent | () | Constructor |
public function KeyboardEvent(type:String, charCode:uint = 0, keyCode:uint = 0, keyLocation:uint = 0, ctrlKey:Boolean = false, altKey:Boolean = false, shiftKey:Boolean = false)
Creates a new KeyboardEvent.
Parameterstype:String | |
charCode:uint (default = 0 )
| |
keyCode:uint (default = 0 )
| |
keyLocation:uint (default = 0 )
| |
ctrlKey:Boolean (default = false )
| |
altKey:Boolean (default = false )
| |
shiftKey:Boolean (default = false )
|
isDefaultPrevented | () | method |
public function isDefaultPrevented():Boolean
Checks whether the preventDefault() method has been called on the event.
ReturnsBoolean |
preventDefault | () | method |
public function preventDefault():void
Cancels the keyboard event's default behavior. This will be forwarded to the native flash KeyboardEvent.
KEY_DOWN | Constant |
public static const KEY_DOWN:String = keyDown
Event type for a key that was pressed.
KEY_UP | Constant |
public static const KEY_UP:String = keyUp
Event type for a key that was released.