Kiwi.Input.Key Class
A compact object that holds the most important details about a Keyboard Event response.
Constructor
Kiwi.Input.Key
-
manager
-
keycode
-
[event]
Parameters:
-
manager
Kiwi.Input.KeyboardThe keyboard manager that this key belongs to.
-
keycode
NumberThe keycode that this key is.
-
[event]
KeyboardEvent optionalThe keyboard event (if there was one) when this was created.
Returns:
This object.
Item Index
Methods
Methods
justPressed
-
[duration]
Returns a boolean indicating whether or not this key was just pressed.
Parameters:
-
[duration]
Number optionalThe duration at which determines if a key was just pressed. Defaults to the managers just pressed rate.
Returns:
justReleased
-
[duration]
Returns a boolean indicating whether or not this key was just released.
Parameters:
-
[duration]
Number optionalThe duration at which determines if a key was just released. Defaults to the managers just pressed rate.
Returns:
objType
()
String
public
The type of object that this is.
Returns:
"Key"
reset
()
public
Resets all of the properties on the Key to their default values.
update
-
event
The 'update' method fires when an event occur's. Updates the keys properties
Parameters:
-
event
KeyboardEvent
Properties
altKey
Boolean
public
If the alt key was held at the time of the event happening.
Default: false
ctrlKey
Boolean
public
If the ctrl key was held at the time of the event happening.
Default: false
duration
Number
public
The duration (in milliseconds) that the key has been down for. This is property is READ ONLY.
Default: 0
isDown
Boolean
public
Indicated whether or not the key is currently down.
Default: false
isUp
Boolean
public
Indicates whether or not the key is currently up.
Default: true
keyCode
Number
public
The keycode that this key is.
preventDefault
Boolean
public
If the default action for this Key should be prevented or not. For example. If your game use's the spacebar you would want its default action (which is to make the website scrolldown) prevented, So you can set this to true.
Default: false
repeats
Number
public
If this key is being 'held' down, this property will indicate the amount of times the 'onkeydown' event has fired. This is reset each time the key is pressed.
Default: 0
shiftKey
Boolean
public
If the shift key was held at the time of the event happening.
Default: false
timeDown
Number
public
The time that the key was pressed initially.
Default: 0
timeUp
Number
public
The time at which the key was released.
Default: 0