phaserjs avatar

Input Keyboard Mouse Touch

This covers Phaser 4's unified input system, the part of the framework you'll interact with constantly for any game with user controls. It walks through keyboard polling with cursor keys and addKey, pointer events for clicks and taps, making Game Objects interactive with setInteractive (including pixel-perfect hit testing), and the full Pointer API with properties like isDown, worldX/worldY, and button states. The source code references are solid (InputPlugin.js, KeyboardPlugin.js, Pointer.js) and the examples show both event-driven and polling patterns. Gamepad support is mentioned but not deeply documented here. If you're building anything beyond a purely reactive game, you'll need the keyboard polling patterns and the distinction between global pointer events versus per-object interactive handlers.

skills.sh installs
1.1K
GitHub stars
40.7K
last updated
Aug 21, 2026

Install

$ npx -y skills add phaserjs/phaser --skill input-keyboard-mouse-touch --agent claude-code

Installs into .claude/skills of the current project.

Files

Input: Keyboard, Mouse, Touch, and Gamepad

Phaser provides a unified input system accessed via this.input in any Scene. It supports keyboard polling and events, mouse/pointer interaction with Game Objects (click, hover, drag), multi-touch, mouse wheel, and gamepad input. Input can be handled through event listeners or by polling state each frame.

Key source paths: src/input/InputPlugin.js, src/input/Pointer.js, src/input/keyboard/KeyboardPlugin.js, src/input/keyboard/keys/Key.js, src/input/keyboard/keys/KeyCodes.js, src/input/keyboard/combo/KeyCombo.js, src/input/gamepad/GamepadPlugin.js, src/input/gamepad/Gamepad.js, src/input/events/, src/input/keyboard/events/ Related skills: ../sprites-and-images/SKILL.md, ../events-system/SKILL.md, ../scenes/SKILL.md

Quick Start (basic keyboard + pointer input)

class MyScene extends Phaser.Scene {
    create() {
        // Keyboard: create cursor keys (up, down, left, right, space, shift)
        this.cursors = this.input.keyboard.createCursorKeys();

Sponsors

Details

Repository
github.com/phaserjs/phaser
First seen
Jun 3, 2026

More from phaserjs/phaser

All 8

Recommended

1juliusbrussee avatarcavemanjuliusbrussee/cavemanUltra-compressed communication mode. Cuts output tokens 65% (measured) by speaking like caveman while keeping full technical accuracy. Supports intensity levels618.3Kskills.sh installs
2mattpocock avatargrill-memattpocock/skillsA relentless interview to sharpen a plan or design.1.5Mskills.sh installs
3shadcn avatarimproveshadcn/improveSurvey any codebase as a senior advisor and produce prioritized, self-contained implementation plans for OTHER models/agents to execute. Strictly read-only on s40Kskills.sh installs
4obra avatarsystematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes326.7Kskills.sh installs
5forrestchang avatarkarpathy-guidelinesforrestchang/andrej-karpathy-skillsBehavioral guidelines to reduce common LLM coding mistakes through explicit assumptions, simplicity, and verifiable success criteria.17.9Kskills.sh installs
6vercel-labs avatarfind-skillsvercel-labs/skillsHelps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express int4.3Mskills.sh installs