kd.Key Class
Represents a key on the keyboard. You'll never actually call this method
directly; Key Objects for every key that Keydrown supports are created for
you when the library is initialized (as in, when the file is loaded). You
will, however, use the prototype
methods below to bind functions to key
states.
Constructor
kd.Key
-
keyCode
Parameters:
-
keyCode
NumberThe keyCode of the key.
Item Index
Methods
Methods
down
-
opt_handler
Bind a function to be called when the key is held down.
Parameters:
-
opt_handler
Function=The function to be called when the key is held down. If omitted, this function invokes whatever handler was previously bound.
isDown
()
Boolean
Returns whether the key is currently pressed or not.
Returns:
True if the key is down, otherwise false.
press
-
opt_handler
-
opt_evt
Bind a function to be called when the key is pressed. This handler will not fire again until the key is released — it does not repeat.
Parameters:
-
opt_handler
Function=The function to be called once when the key is pressed. If omitted, this function invokes whatever handler was previously bound.
-
opt_evt
KeyboardEvent=If this function is being called by the keydown event handler, this is the raw KeyboardEvent Object provided from the browser. This should generally not be provided by client code.
up
-
opt_handler
-
opt_evt
Bind a function to be called when the key is released.
Parameters:
-
opt_handler
Function=The function to be called when the key is released. If omitted, this function invokes whatever handler was previously bound.
-
opt_evt
KeyboardEvent=If this function is being called by the keyup event handler, this is the raw KeyboardEvent Object provided from the browser. This should generally not be provided by client code.