input-keyboard-mouse-touch

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Handling user input in Phaser games requires knowing many APIs: keyboard polling and events, pointer and touch handling, interactive hit areas, drag and drop, and gamepad support. This Skill consolidates those patterns so you can wire up input correctly 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, Mouse, and Touch: Handle clicks, hover, wheel, multi-touch pointers, pointer lock, and right-click, with three levels of event dispatch (Game Object, Scene per-object, Scene global). - Drag and Drop: Make objects draggable, configure drop zones, and tune drag distance and time thresholds. - Gamepad Support: Poll sticks, buttons, and D-pad, listen for connect/disconnect events, and trigger vibration. - Use Case: You are building a Phaser scene where players drag floppy disk sprites into drive bays and press spacebar to confirm. This Skill gives you the exact setInteractive, setDraggable, drop zone, and keyboard event code to implement it. ## Quick Start Ask the AI to make a Phaser sprite clickable and draggable with a drop zone, and to add keyboard controls using cursor keys and a spacebar action.

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 handle keyboard input in Phaser?

Use this.input.keyboard.createCursorKeys() for arrow keys or addKey('W') for specific keys, then poll key.isDown in update() or use Phaser.Input.Keyboard.JustDown(key) for single presses. You can also listen for events like 'keydown-SPACE' on this.input.keyboard.

How do I make a Phaser sprite clickable?

Call sprite.setInteractive() to enable input using the texture frame as the hit area, then listen with sprite.on('pointerdown', callback). You can pass custom shapes like Phaser.Geom.Circle or enable pixel-perfect hit testing via the config object.

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.

Does Phaser support gamepad input?

Yes, enable it with input: { gamepad: true } in the game config, then access pads via this.input.gamepad.pad1 through pad4. Poll buttons like pad.A and sticks like pad.leftStick in update(), or listen for 'connected' and 'down' events.

Why is my Phaser pointerdown event not firing on a sprite?

The most common cause is forgetting to call setInteractive() on the Game Object before attaching listeners. Containers additionally need setSize() or an explicit hit area shape, and input events do not fire during the preload phase.

Why does JustDown only work once in Phaser?

Phaser.Input.Keyboard.JustDown consumes the 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.