input-keyboard-mouse-touch

Implements keyboard, mouse, touch, drag-and-drop, and gamepad input handling in Phaser 4 scenes.

Updated Jul 13, 2026
One-click install
npx skills add https://github.com/russellmorgan/UnderConstruction --skill input-keyboard-mouse-touch-russellmorgan
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: input-keyboard-mouse-touch
Source: https://github.com/russellmorgan/UnderConstruction/tree/main/.claude/skills/input-keyboard-mouse-touch
Command: npx skills add https://github.com/russellmorgan/UnderConstruction --skill input-keyboard-mouse-touch-russellmorgan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Handling user input in Phaser 4 games requires knowing a large API surface: keyboard polling versus events, pointer coordinates, hit areas, drag thresholds, and gamepad state. This Skill consolidates those patterns so you can wire up clicks, key presses, multi-touch, and controllers without digging through Phaser source files. ## Core Features & Use Cases - Keyboard Input: Create cursor keys, register individual keys with addKey/addKeys, poll with isDown or JustDown, listen for keydown events, and build key combos like the Konami code. - Pointer and Touch: Handle pointerdown/pointermove events at three dispatch levels, configure custom hit areas (circle, polygon, pixel-perfect), support multi-touch with up to 10 pointers, and use pointer lock for FPS-style controls. - Drag and Drop: Make Game Objects draggable, define drop zones, and tune drag distance and time thresholds. - Gamepad Support: Poll sticks, buttons, and triggers from up to four controllers, with connection events and vibration. - Use Case: You are building a timing-based browser game where the player presses Space or taps to release a ball. Use this Skill to set up the keyboard listener, the pointerdown handler for touch, and Esc-to-pause in one scene. ## Quick Start Ask the AI to set up a Phaser scene where pressing Space or clicking the canvas triggers an action, using this input skill.

Frequently Asked Questions about input-keyboard-mouse-touch

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I detect a key press in Phaser?▼

Create a Key object with this.input.keyboard.addKey('SPACE') or use createCursorKeys() for arrows. Poll key.isDown each frame in update(), or use Phaser.Input.Keyboard.JustDown(key) to fire once per press. You can also listen for the 'keydown-SPACE' event.

How to make a sprite clickable in Phaser 4?▼

Call sprite.setInteractive() to enable input using the texture frame as the hit area, then listen with sprite.on('pointerdown', handler). For irregular shapes, pass a Phaser.Geom shape like Circle or Polygon with its Contains callback.

Does Phaser support gamepad input?▼

Yes, enable it with input: { gamepad: true } in the game config, then access controllers via this.input.gamepad.pad1 through pad4. Poll buttons, d-pad, and analog sticks in update(), or listen for 'connected' and 'down' events. HTTPS is required in modern browsers.

Why is my Phaser pointerdown event not firing on a Game Object?▼

The most common cause is forgetting to call setInteractive() on the Game Object before adding listeners. Containers additionally need setSize() or an explicit hit area shape, and drag events require setDraggable() in addition to setInteractive().

How do I implement drag and drop in Phaser?▼

Call setInteractive() on the object, then this.input.setDraggable(sprite) or use the { draggable: true } config. Listen for 'dragstart', 'drag', and 'dragend' on this.input, and create drop zones with zone.setRectangleDropZone() to receive 'drop' events.

Why does JustDown return true only once in Phaser?▼

Phaser.Input.Keyboard.JustDown consumes the press flag when read, so calling it twice in the same frame returns true then false. Store the result in a variable if you need the value in multiple places within one frame.