Keyboard, mouse, and gamepad input handling
Unified input system supporting keyboard, mouse, and gamepad with button state tracking.
Checks if a button is currently held down.
if (btn(0)) player.x -= 2; // Move left
Checks if a button was just pressed (one-shot).
if (btnp(4)) player.jump(); // Jump on Z key press
Checks if a specific keyboard key is currently held.
if (isKeyDown("w")) player.moveForward();
Checks if a key was just pressed (one-shot).
if (isKeyPressed("Enter")) selectMenuItem();
Gets the current mouse X position (0-640).
const mx = mouseX();
Gets the current mouse Y position (0-360).
const my = mouseY();
Checks if mouse button is held.
if (mouseDown()) dragObject();
Checks if mouse button was just clicked (one-shot).
if (mousePressed()) handleClick();
Checks if a gamepad is connected.
if (gamepadConnected()) useAnalogStick();
Gets left analog stick X axis (-1.0 to 1.0).
player.x += leftStickX() * speed;
Gets left analog stick Y axis (-1.0 to 1.0).
player.y += leftStickY() * speed;
Gets right analog stick X axis.
camera.rotateY(rightStickX() * 0.05);
Gets right analog stick Y axis.
camera.rotateX(rightStickY() * 0.05);