Tracks and provides access to keyboard input state from the previous frame. Uses the standardized code property from JavaScript KeyboardEvents to identify keys. Provides methods to check if individual keys or combinations of keys are pressed.
code
KeyboardEvent: code property
const keyboard = this.inputManager.keyboard;if (keyboard.isPressed("ArrowRight")) { // if the right arrow key is pressed, do some action}if (keyboard.orPressed("Enter", "Space")) { // if the enter key or space key are pressed, do some action}if (keyboard.andPressed("ControlLeft", "KeyC")) { // if the left control key and the letter C key are pressed, do some action} Copy
const keyboard = this.inputManager.keyboard;if (keyboard.isPressed("ArrowRight")) { // if the right arrow key is pressed, do some action}if (keyboard.orPressed("Enter", "Space")) { // if the enter key or space key are pressed, do some action}if (keyboard.andPressed("ControlLeft", "KeyC")) { // if the left control key and the letter C key are pressed, do some action}
The current pressed key codes
Returns TRUE if all the given keys are being pressed.
The codes of the keys to check
TRUE for pressed, FALSE instead
This method accepts two parameters that will be returned depending on whether all the given keys are being pressed.
The value to return if the key is pressed
The value to return if the key is not pressed
The returnTrue for pressed or the returnFalse instead
Returns TRUE if the given key is being pressed.
The code of the key to check
TRUE true for pressed, FALSE instead
This method accepts two parameters that will be returned depending on whether the key is pressed or not.
Returns TRUE if one of the given keys is being pressed.
This method accepts two parameters that will be returned depending on whether one of the given keys is being pressed.
Tracks and provides access to keyboard input state from the previous frame. Uses the standardized
code
property from JavaScript KeyboardEvents to identify keys. Provides methods to check if individual keys or combinations of keys are pressed.See
KeyboardEvent: code property
Example