keys
is an instance of FlxKeyboard
- a helper object that is used to track keyboard input.
// Detect if the up arrow key is pressed
if (FlxG.keys.pressed.UP)
{
sprite.velocity.y = -100;
}
It’s also easy to detect a key press among various keys.
// Detect if either the W key or the up arrow key is pressed
if (FlxG.keys.anyPressed([UP, W]))
{
sprite.velocity.y = -100;
}