input-keyboard-mouse-touch

Implement keyboard, mouse, touch, and gamepad input handling in Phaser 4 games.

465|41|Updated Aug 4, 2026
One-click install
npx skills add https://github.com/autonomous-ai/openharness --skill input-keyboard-mouse-touch-autonomous-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: input-keyboard-mouse-touch
Source: https://github.com/autonomous-ai/openharness/tree/main/store/agents/phaser/skills/input-keyboard-mouse-touch
Command: npx skills add https://github.com/autonomous-ai/openharness --skill input-keyboard-mouse-touch-autonomous-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Handling user input in Phaser games requires knowing a large API surface spanning keyboard polling, pointer events, drag and drop, hit areas, and gamepads. This Skill provides the correct event names, callback signatures, and configuration patterns so you avoid common mistakes like forgetting setInteractive or misreading pointer coordinates. ## Core Features & Use Cases - Keyboard Input: Create cursor keys, bind individual keys with addKey, poll with isDown or JustDown, capture keys to prevent browser defaults, and detect key combos like the Konami code. - Pointer and Touch Input: Handle clicks, hover, mouse wheel, multi-touch with up to 10 pointers, pointer lock for FPS-style controls, and custom hit areas including pixel-perfect testing. - Drag and Drop: Make Game Objects draggable, define drop zones, and respond to dragstart, drag, dragend, and drop events with configurable distance and time thresholds. - Gamepad Support: Poll analog sticks, D-pad, face buttons, and triggers from up to four gamepads, with connection events and vibration effects. - Use Case: Build a platformer where the player moves with WASD or arrow keys, jumps with spacebar via JustDown, drags inventory items into equipment slots, and supports an Xbox controller as an alternative input device. ## Quick Start Add keyboard movement and click handling to my Phaser scene using cursor keys for movement and pointerdown events on interactive sprites.

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-time presses use Phaser.Input.Keyboard.JustDown(key), or listen for 'keydown-SPACE' style events.

How to make a sprite clickable in Phaser?

Call sprite.setInteractive() first, then attach sprite.on('pointerdown', callback). Without setInteractive, pointer events never fire on the object. You can pass custom shapes like Circle or Polygon for the hit area.

How do I implement drag and drop in Phaser?

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

Does Phaser support gamepad controllers?

Yes, enable input.gamepad in the game config and access pads via this.input.gamepad.pad1 through pad4. Poll buttons like pad.A and sticks like pad.leftStick in update(). Note browsers require HTTPS and a button press before exposing gamepads.

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

The most common cause is missing setInteractive() on the Game Object. Containers additionally need setSize() or an explicit hit area shape. Also check that this.input.topOnly is not blocking objects underneath another interactive object.

How do I detect multi-touch input in Phaser?

Phaser creates 2 pointers by default; call this.input.addPointer(n) for more, up to 10 total. Access them via this.input.pointer1 through pointer10, and check pointer.wasTouch to distinguish touch from mouse input.