input-keyboard-mouse-touch

Unify keyboard, mouse, touch, pointer, drag, and gamepad input for Phaser 4 scenes.

40.1k|7.2k|Updated Apr 12, 2013
One-click install
npx skills add https://github.com/phaserjs/phaser --skill input-keyboard-mouse-touch-phaserjs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: input-keyboard-mouse-touch
Source: https://github.com/phaserjs/phaser/tree/main/skills/input-keyboard-mouse-touch
Command: npx skills add https://github.com/phaserjs/phaser --skill input-keyboard-mouse-touch-phaserjs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Phaser 4's input system is complex, spanning keyboard, mouse, touch, pointer, drag-and-drop, hit areas, interactive objects, and gamepad. This skill provides a unified input layer that centralizes handling across scenes, making it easier to respond to user actions consistently.

Core Features & Use Cases

  • Unified input API accessed via this.input for per-scene and per-object events.
  • Keyboard: createCursorKeys, addKey/addKeys, event listeners, and key combos.
  • Pointer & Game Object events: pointerdown/over/move on interactive objects and scene-level pointer events.
  • Drag and Drop: draggable objects, drag events, and drop zones.
  • Hit testing: configurable hit areas (rectangles, circles, polygons) and pixel-perfect options.
  • Gamepad support: plug-in style gamepad input, axes and buttons.
  • Pointer lock and multi-pointer support: pointer lock usage and additional pointers.

Quick Start

Create a Scene, set up interactive objects with setInteractive(), and start listening for keyboard and pointer events.

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, mouse, and touch input in Phaser 4?

You can set up drag and drop in Phaser by configuring game objects with setInteractive() and making them draggable, then listening for drag events and defining drop zones to handle object movement and placement.

How does hit testing work for interactive game objects in Phaser?

Hit testing in Phaser supports configurable hit areas on interactive objects, allowing you to use rectangles, circles, polygons, or pixel-perfect options to accurately detect pointer collisions.

Can I use gamepad and multi-pointer support in Phaser games?

Yes, Phaser games support plug-in style gamepad input with axes and buttons, alongside multi-pointer support and pointer lock for handling multiple simultaneous user interactions.

What is the best way to manage scene-wide and per-object input events in Phaser?

The best way to manage input events in Phaser is using the unified input layer, which exposes comprehensive properties and methods for listening to both scene-wide and per-object pointer interactions.