Keyboard Class
Controls keyboard input
Constructor
Item Index
Properties
- _clearSq
- game
- KEY static
- sequence
- sequenceTimeout
Methods
_clearSequence
()
private
Clears the current sequence so that a new one can start
_getEventData
-
event
-
down
Generates an event data object for a keyboard event
Parameters:
-
event
DOMEventThe original DOMEvent that was passed into the raw event handler
-
down
BooleanIs this a keydown event
Returns:
The event object
emit
-
type
-
data
Emits an event which will run all registered listeners for the event type
Parameters:
-
type
StringThe event name to emit
-
data
MixedAny data you want passed along with the event
Returns:
Returns itself.
modifyKey
-
event
-
key
-
down
Called when a key state has changed, updates current sequence and emits events
Parameters:
-
event
DOMEvent -
key
NumberThe key code that has changed
-
down
BooleanWhether the key has been pressed or not
off
-
type
-
listener
Removes a listener function for an event type
Parameters:
-
type
StringThe event name to emit
-
listener
FunctionThe function to remove
Returns:
Returns itself.
on
-
type
-
listener
Registers a listener function to be run on an event occurance
Parameters:
-
type
StringThe event name to listen for
-
listener
FunctionThe function to execute when the event happens
Returns:
Returns itself.
once
-
type
-
listener
Registers a one-time callback for an event
Parameters:
-
type
StringThe event name to listen for
-
listener
Functionthe callback to call when the event occurs
Returns:
Returns itself.
onKeyDown
-
event
-
override
Called when a key is pressed down
Parameters:
-
event
DOMEvent -
override
NumberThe key code to use instead of checking event data
onKeyUp
-
event
-
override
Called when a key is released
Parameters:
-
event
DOMEvent -
override
NumberThe key code to use instead of checking event data
Properties
_clearSq
Number
private
The timeout ID for the wait to clear the input sequence
KEY
Object
static
Bindable keycodes
sequence
ArrayThe current sequence of keys that have been pressed
sequenceTimeout
Number
The amount of time it takes for the sequence to clear out, in ms
Default: 500