craftyjs.github.com

Keyboard

Give entities keyboard events (keydown and keyup).

Back to top

.isDown

public Boolean isDown(String keyName)

keyName
Name of the key to check. See Crafty.keys.

public Boolean isDown(Number keyCode)

keyCode
Key code in Crafty.keys.

Determine if a certain key is currently down.

Example

entity.requires('Keyboard').bind('KeyDown', function () { if (this.isDown('SPACE')) jump(); });

See Also