$npx -y skills add TabooHarmony/roblox-brain --skill roblox-inputUse when handling Roblox keyboard, mouse, gamepad, touch, motion input, or cross-platform action binding.
| 1 | ## When to Load |
| 2 | |
| 3 | Load for keyboard, mouse, gamepad, touch, motion, or cross-platform action binding. Client-side only. For simulation-affecting input in a Server Authority project, use the Input Action System rather than traditional input events. |
| 4 | |
| 5 | ## Quick Reference |
| 6 | |
| 7 | **Core events** (`UserInputService`): `InputBegan`, `InputChanged`, `InputEnded` fire as `(input: InputObject, gameProcessedEvent: boolean)`. `InputBegan` does NOT fire for mouse wheel. Events only fire while the client window is focused. |
| 8 | |
| 9 | **Prefer `ContextActionService` over `InputBegan`** for gameplay — free conflict resolution (chat won't steal H) and free mobile buttons: |
| 10 | |
| 11 | ```luau |
| 12 | local CAS = game:GetService("ContextActionService") |
| 13 | |
| 14 | local function onAction(name, state, _input) |
| 15 | if name == "Jump" and state == Enum.UserInputState.Begin then |
| 16 | humanoid.Jump = true |
| 17 | end |
| 18 | end |
| 19 | |
| 20 | CAS:BindAction("Jump", onAction, true, |
| 21 | Enum.KeyCode.Space, Enum.KeyCode.ButtonA) |
| 22 | ``` |
| 23 | |
| 24 | `BindAction(name, handler, createTouchButton, ...inputTypes)`. Handler returns `ContextActionResult.Sink` to consume, `.Pass` to fall through. |
| 25 | |
| 26 | **Server Authority:** use `InputAction`/`InputContext` for inputs that affect the core simulation, store the input state where the synchronized simulation can read it, and process it through `RunService:BindToSimulation()`. `ContextActionService` remains appropriate for UI-only or classic-project actions. |
| 27 | |
| 28 | **Gamepad UI focus:** separate gameplay bindings from menu selection. Set `GuiService.SelectedObject`, mark controls `Selectable`, and test nested/modal navigation. |
| 29 | |
| 30 | **Gamepad:** use `GetConnectedGamepads()` and listen to connection changes. |
| 31 | |
| 32 | **Touch:** use high-level gesture events or raw `TouchStarted`/`TouchMoved`/`TouchEnded` when tracking fingers. |
| 33 | |
| 34 | **Pitfalls**: |
| 35 | - `gameProcessedEvent=true` in InputBegan → UI consumed it. Filter for gameplay. |
| 36 | - `BindAction` is stack-based: most-recent wins. Use `BindActionAtPriority`. |
| 37 | - Client-only. Server scripts silently no-op. |
| 38 | - `JumpRequest` fires multiple times per jump — debounce. |
| 39 | - Mouse wheel only fires `InputChanged`. |
| 40 | |
| 41 | Full event tables and polling methods: `references/full.md`. |