input-keyboard-mouse-touch

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

Updated Sep 20, 2026
One-click install
npx skills add https://github.com/AmirOssanloo/helix-game --skill input-keyboard-mouse-touch-amirossanloo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: input-keyboard-mouse-touch
Source: https://github.com/AmirOssanloo/helix-game/tree/main/.claude/skills/input-keyboard-mouse-touch
Command: npx skills add https://github.com/AmirOssanloo/helix-game --skill input-keyboard-mouse-touch-amirossanloo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Handling user input in Phaser 4 games involves many APIs—keyboard polling, pointer events, drag and drop, hit areas, and gamepads—and getting the details right (event levels, hit testing, multi-touch) is error-prone without a consolidated reference. ## Core Features & Use Cases - Keyboard Input: Create cursor keys, register individual keys, poll with isDown/JustDown, listen to keydown events, and build key combos like the Konami code. - Pointer and Drag Handling: Make Game Objects interactive with setInteractive, handle clicks and hover at three event levels, configure custom hit areas, and implement drag-and-drop with drop zones. - Gamepad and Multi-touch: Poll gamepad sticks and buttons, handle connection events, and configure multiple pointers for touch devices. - Use Case: You are building a hero-combat game and need WASD movement, spacebar to cast spells, clickable UI sprites, and gamepad support—this Skill provides the exact Phaser 4 patterns and gotchas for each. ## Quick Start Use the input-keyboard-mouse-touch skill to add WASD movement and a clickable attack button 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('W') for specific keys, then poll key.isDown in update(). For one-shot presses use Phaser.Input.Keyboard.JustDown(key), or listen to 'keydown-SPACE' style events.

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', callback). You can pass custom Geom shapes like Circle or Polygon for irregular hit areas.

How do I implement drag and drop in Phaser?▼

Call setInteractive() on the object, then this.input.setDraggable(sprite), and handle 'dragstart', 'drag', and 'dragend' events on this.input. Create drop zones with zone.setRectangleDropZone() and listen for the 'drop' event.

Does Phaser support gamepad input?▼

Yes, enable it with input: { gamepad: true } in the game config, then access 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() 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 Phaser gamepad not work in my browser?▼

Modern browsers like Chrome require HTTPS for the Gamepad API, and many require a button press before exposing the device. Also check this.input.gamepad.total on scene start since 'connected' only fires for new connections.