Manages input sources including keyboard, mouse, gamepad and touch screen interactions.
Provides methods to check key states, mouse position/buttons, gamepad inputs and touch events.

// Keyboard input
if (inputManager.keyboard.isPressed("Space")) {
// Jump action
}

// Multiple key checks
if (inputManager.keyboard.orPressed(["Enter", "Space"])) {
// Action for either key pressed
}

if (inputManager.keyboard.andPressed(["ControlLeft", "KeyC"])) {
// Action for both keys pressed together
}

// Mouse input
const mousePos = inputManager.mouse.positionInViewport;
if (inputManager.mouse.leftButtonPressed) {
// Shoot action
}

// Mouse wheel scrolling
const scrollAmount = inputManager.mouse.wheelScroll;

// Gamepad input
const gamepad = inputManager.gamepads[0];
if (gamepad?.bottomFace) {
// Bottom face button pressed (A on Xbox, B on Nintendo, X on PlayStation)
}

// Gamepad stick movement
const leftStickPos = gamepad?.leftStickAxes;
const rightStickPos = gamepad?.rightStickAxes;

// Gamepad vibration
gamepad?.vibrate(200, 0.5, 0.5);

// Touch input
if (inputManager.touchScreen.touching) {
const touch = inputManager.touchScreen.interactions[0];
// Handle touch at touch.positionInViewport
}

Constructors

Properties

gamepads: GamepadController[]

Manages gamepads information.

keyboard: Keyboard

Manages mouse information.

mouse: Mouse

Manages keyboard information.

touchScreen: TouchScreen

Manages touch screen information.