input-keyboard-mouse-touch
БесплатноБез исполняемых скриптовНе проверенUse this skill when handling user input in Phaser 4. Covers keyboard keys, mouse clicks and movement, touch events, pointer handling, drag and drop, hit…
от phaserjs★ 40 842 звезды на GitHubОб этом скилле
Input: Keyboard, Mouse, Touch, and Gamepad
Phaser provides a unified input system accessed via
this.inputin 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();
// Keyboard: listen for a specific key event
this.input.keyboard.on('keydown-SPACE', (event) => {
console.log('Space pressed');
});
// Pointer: listen for click/tap anywhere on the game canvas
this.input.on('pointerdown', (pointer) => {
console.log('Clicked at', pointer.x, pointer.y);
});
// Pointer: make a Game Object interactive and clickable
const sprite = this.add.sprite(400, 300, 'player');
sprite.setInteractive();
sprite.on('pointerdown', (pointer, localX, localY, event) => {
console.log('Sprite clicked at local', localX, localY);
});
}
update() {
// Poll cursor keys each frame
if (this.cursors.left.isDown) {
// move left
}
if (this.cursors.right.isDown) {
// move right
}
if (Phaser.Input.Keyboard.JustDown(this.cursors.space)) {
// fire once per press
}
}
}
Core Concepts
The Input Plugin (this.input)
Accessed via this.input in any Scene. It is an EventEmitter that handles all input for that Scene.
Key properties:
this.input.enabled(boolean) - toggle input processing for the Scenethis.input.topOnly(boolean, defaulttrue) - only emit events from the top-most Game Object under the pointerthis.input.keyboard- the KeyboardPlugin instancethis.input.gamepad- the GamepadPlugin instancethis.input.mouse- the MouseManager referencethis.input.activePointer- the most recently active Pointerthis.input.mousePointer- the mouse Pointer (pointers[0], distinct from pointer1 which is the first touch)this.input.pointer1throughthis.input.pointer10- individual pointer referencesthis.input.dragDistanceThreshold(number, default 0) - pixels a pointer must move before drag startsthis.input.dragTimeThreshold(number, default 0) - ms a pointer must be held before drag startsthis.input.pollRate(number, default -1) - how often pointers are polled; 0 = every frame, -1 = only on movement
Key methods:
addPointer(quantity)- add extra pointers for multi-touch (default is 2; max 10)setHitArea(gameObjects, hitArea, hitAreaCallback)- set custom hit area on Game ObjectssetHitAreaCircle(gameObjects, x, y, radius, callback)setHitAreaEllipse(gameObjects, x, y, width, height, callback)setHitAreaRectangle(gameObjects, x, y, width, height, callback)setHitAreaTriangle(gameObjects, x1, y1, x2, y2, x3, y3, callback)setHitAreaFromTexture(gameObjects, callback)- use the texture frame dimensionssetDraggable(gameObjects, value)- enable or disable draggingmakePixelPerfect(alphaTolerance)- returns a callback for pixel-perfect hit testing
Pointers
A Pointer object encapsulates both mouse and touch input. By default Phaser creates 2 pointers. Use this.input.addPointer(quantity) for more (up to 10 total).
Key properties:
x,y- position in screen space (read fromposition.x,position.y)worldX,worldY- position translated through the most recent CameradownX,downY- position when button was pressedupX,upY- position when button was releasedisDown(boolean) - true if any button is heldprimaryDown(boolean) - true if primary button (left click / touch) is heldbutton(number) - which button was pressed/released (0=left, 1=middle, 2=right)buttons(number) - bitmask of currently held buttons (1=left, 2=right, 4=middle, 8=back, 16=forward)wasTouch(boolean) - true if input came from touchvelocity(Vector2) - smoothed velocity of pointer movementangle(number) - angle of movement in radiansdistance(number) - smoothed distance moved per framemovementX,movementY- relative movement when pointer is lockeddeltaX,deltaY,deltaZ- mouse wheel scroll amountslocked(boolean)
Установить input-keyboard-mouse-touch в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл input-keyboard-mouse-touch?
Use this skill when handling user input in Phaser 4. Covers keyboard keys, mouse clicks and movement, touch events, pointer handling, drag and drop, hit areas, interactive objects, and gamepad support. Triggers on: keyboard, mouse, touch, pointer, drag, drop, click, input, gamepad, cursor keys.
Как установить скилл input-keyboard-mouse-touch?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл input-keyboard-mouse-touch запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic