input-keyboard-mouse-touch

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

2|10|Updated Jul 28, 2026
One-click install
npx skills add https://github.com/kodingvibes/gamejam-2026 --skill input-keyboard-mouse-touch-kodingvibes
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: input-keyboard-mouse-touch
Source: https://github.com/kodingvibes/gamejam-2026/tree/main/participantes/jpyunism/.agents/skills/input-keyboard-mouse-touch
Command: npx skills add https://github.com/kodingvibes/gamejam-2026 --skill input-keyboard-mouse-touch-kodingvibes

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Handling user input in Phaser games involves many APIs—keyboard polling, pointer events, hit areas, drag-and-drop, and gamepads—and getting the details right (event levels, JustDown semantics, hit area shapes) is error-prone without a reference. ## Core Features & Use Cases - Keyboard Input: Create cursor keys, register individual keys with addKey/addKeys, poll with isDown or JustDown, listen to keydown events, and build key combos like the Konami code. - Pointer and Touch Input: Handle clicks, hover, mouse wheel, multi-touch pointers, pointer lock, and right-click via a unified Pointer API. - Interactive Objects and Drag-and-Drop: Make Game Objects clickable with setInteractive, define geometric or pixel-perfect hit areas, and implement drag-and-drop with drop zones. - Gamepad Support: Poll sticks, buttons, and D-pad, listen for connect/disconnect events, and trigger vibration effects. - Use Case: Build a platformer where the player moves with WASD or arrow keys, jumps with spacebar, drags inventory items into slots with the mouse, and supports an Xbox controller as an alternative input device. ## Quick Start Use the input-keyboard-mouse-touch skill to add keyboard movement, clickable sprites, and drag-and-drop to my Phaser scene.

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/addKeys for specific keys like WASD. Poll key.isDown in update() for held keys, or use Phaser.Input.Keyboard.JustDown(key) for one-time presses, and listen to 'keydown-KEY' events for event-driven handling.

How to make a sprite clickable in Phaser?▼

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 and enable dragging with this.input.setDraggable(sprite) or the { draggable: true } config. Then handle 'dragstart', 'drag', and 'dragend' events, 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 this.input.gamepad. Poll pad1 through pad4 for sticks, buttons, and D-pad state, or listen for 'connected', 'down', and 'up' events. Note browsers require HTTPS and a button press first.

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

The most common cause is forgetting to call setInteractive() before attaching listeners. Containers also need setSize() or an explicit shape for hit testing, and drag events additionally require setDraggable().

Why does JustDown only work once in Phaser keyboard input?▼

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.