Namespace

Keyboard

Keyboard

Methods

# registerKeyDown(key, callback, globalScopeopt)

Registers a keyDown listener for a specific key, for a list of valid key values see: http://craftyjs.com/api/Crafty-keys.html The callback function will continue to be invoked for every keyDown event until it is unregistered.
Parameters:
Name Type Attributes Default Description
key string The key to listen to.
callback Callback The callback function to invoke when the keyDown event fires.
globalScope boolean <optional>
false Is this for use outside of the program itself?

View Source rpgcode.js, line 2360

Example
rpgcode.registerKeyDown("ENTER", function(e) {
 rpgcode.log(e.key + " key is down!");
});

# registerKeyUp(key, callback, globalScopeopt)

Registers a keyUp listener for a specific key, for a list of valid key values see: http://craftyjs.com/api/Crafty-keys.html The callback function will continue to be invoked for every keyUp event until it is unregistered.
Parameters:
Name Type Attributes Default Description
key string The key to listen to.
callback Callback The callback function to invoke when the keyUp event fires.
globalScope boolean <optional>
false Is this for use outside of the program itself?

View Source rpgcode.js, line 2386

Example
rpgcode.registerKeyUp("ENTER", function() {
 rpgcode.log("Enter key is up!");
});

# unregisterKeyDown(key, globalScopeopt)

Removes a previously registered KeyDown listener.
Parameters:
Name Type Attributes Default Description
key string The key associated with the listener.
globalScope boolean <optional>
false Is this a global scope key down handler.

View Source rpgcode.js, line 3370

Example
rpgcode.unregisterKeyDown("ENTER");

# unregisterKeyUp(key, globalScopeopt)

Removes a previously registered KeyUp listener.
Parameters:
Name Type Attributes Default Description
key string The key associated with the listener.
globalScope boolean <optional>
false Is this a global scope key up handler.

View Source rpgcode.js, line 3389

Example
rpgcode.unregisterKeyUp("ENTER");