jperezdelreal/firstframestudios/input-handling
Claude Code and agent skill by jperezdelreal/firstframestudios
- community
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install jperezdelreal/firstframestudios/input-handlingSKILL.md
The same SKILL.md was published earlier as jperezdelreal/firstframestudios/input-handling.
SKILL: Input Handling
Input is the player's direct voice to the game. Input latency budget, buffering strategies, platform-specific handling, and accessibility through remapping transform input from technical detail into a core pillar of game feel.
name: "input-handling" description: "Universal input system design — buffering, latency budgets, action mapping, multiplatform support, accessibility, testing patterns" domain: "engine-architecture" confidence: "medium" source: "firstPunch (Canvas keyboard), patterns universal across all engines/genres" has_reference: true
Context
Use when building new game input architecture, transitioning engines, game feels unresponsive/"eats inputs", supporting multiple input methods (keyboard/gamepad/touch), implementing accessibility (remapping), or for any genre where input feel matters. Not for simple UI pointer/click, turn-based strategy, or 3D games with built-in input systems (though read Principle #2).
Core Patterns
Latency Budget: Total ≤ 100ms
Input → Game Loop → Update → Render → Display = ~8-50ms total. Input systems must consume < 8ms (ideally < 1ms). Players notice delays ≥ 50ms. Every 16.7ms = 1 frame at 60 FPS.
Input Buffering: Ring Buffer Pattern
Store recent inputs (6-10 frames, 100-167ms window). Players press faster than state machines consume. Without buffering, inputs vanish ("eaten input" feel).
Clear strategically: Clear on state entry (attack → recovery) to prevent stacking. Don't clear on safe transitions (idle → attack).
Coyote Time / Grace Periods
Allow action slightly after valid window closes. Jump allowed 4-6 frames (67-100ms) after leaving ground. Human reaction time ≈ 200ms, so by time finger hits button, window has closed. Coyote time is generous design, not a bug.
Tuning: Jump after ground: 100-150ms. Defend after hit: 50-100ms. Grab startup: 30-50ms. Start generous (120ms), tighten if playtesting requires.
Action Mapping: Abstract from Physical Keys
Benefits: Remappable, portable (keyboard → gamepad), testable, accessible.
Action Types: PRESS (discrete, 1 frame), HOLD (continuous), RELEASE (trigger on key-up), DOUBLE_TAP (2 presses in window), CHARGE (hold > duration).
Key Examples
Directional Input: Last-Pressed Wins
Player presses Left then Right quickly. Both arrive same frame. Intent: "switch to right." Solution: timestamp each press, last-pressed wins.
Input Priority & Consumption
Simultaneous actions need priority queue. Pause (priority 0, highest) > hit (90) > attack (80) > dodge (75) > jump (70) > movement (50) > idle (0). When one system handles input, others don't see it ("consumption").
Platform-Specific
Keyboard: Key repeat (ignore e.repeat), focus loss (clear on blur), modifier keys (Shift/Ctrl/Alt).
Gamepad: Dead zones (20% typical), pressure sensitivity, vibration API, multiple gamepads. Analog stick: applyDeadZone(value) { if (abs(value) < 0.2) return 0; }.
Touch: Virtual buttons, gesture recognition (tap, swipe, hold), visual feedback, variable screen sizes. Render buttons, detect touch in button bounds.
Anti-Patterns
- Raw Polling Only: No buffering.
if (input.isHeld('attack')) attack();executes every frame. Fix: Use buffer + state transitions. - Fixed Key Mapping: No remapping. Accessibility failure. Fix: InputMapper with configurable bindings.
- Input in Render Loop: Frame-dependent behavior. Fix: Process input in
update(), notrender(). - Eating Inputs Silently: Menu closes, game doesn't see input. Fix: InputConsumer pattern.
- No Coyote Time: Tight windows, unforgiving. Fix: Add 6f grace after leaving ground.
Full details: See REFERENCE.md for complete ring buffer implementation, coyote window patterns, input mapper architecture, directional input, priority/conflict resolution, platform-specific handlers (keyboard/gamepad/touch), cross-platform unified API, debug overlays, input recording/playback, latency measurement, firstPunch learnings (recursion bug fix), and checklist for any game.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.squad/skills/input-handling/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/jperezdelreal/firstframestudios/input-handling)