What problem does it solve?
It solves the challenge of implementing reliable, cross-device user input in Phaser games by unifying keyboard, mouse, touch/pointer, drag-and-drop, hit testing, and gamepad handling under a consistent API.
Core Features & Use Cases
- Keyboard input (polling and events): Use cursor keys, addKey/addKeys, JustDown/JustUp, and key combinations for responsive character controls and UI hotkeys.
- Pointer/mouse/touch interaction: Listen to scene-level pointer events and Game Object-level interactive events for clicks, hover, movement, wheel, and pointer lock.
- Interactive gameplay mechanics: Enable drag-and-drop with draggable Game Objects and drop zones, and fine-tune interaction using hit areas (including pixel-perfect) for accurate selection.
- Gamepad support: Read D-pad, face buttons, analog sticks, and handle connection/disconnection and button events.
Quick Start
Enable keyboard controls with this.input.keyboard.createCursorKeys, make a sprite interactive with setInteractive, then use scene-level pointerdown to react to clicks or taps and update movement logic in update() based on isDown/JustDown.