The s&boxDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/facepunch/sbox-public/llms.txt
Use this file to discover all available pages before exploring further.
Input class is a static API for reading player input inside your components. Rather than polling raw keys, you define named actions that map to keyboard keys, gamepad buttons, or VR controls — and query them with Input.Pressed, Input.Down, and Input.Released. This page covers action bindings, all three query methods, mouse and analog values, gamepad support, and VR.
Action bindings
Actions are named input events defined in your project’s Input Settings asset (a JSON file). Each action has a name, an optional keyboard binding, and an optional gamepad binding. The engine ships with a set of default common actions for games that do not define their own.Default common actions
| Action | Default keyboard | Gamepad | Group |
|---|---|---|---|
Forward | W | — | Movement |
Backward | S | — | Movement |
Left | A | — | Movement |
Right | D | — | Movement |
Jump | Space | A Button | Movement |
Run | Shift | Left Joystick Button | Movement |
Duck | Ctrl | B Button | Movement |
Attack1 | Mouse1 | Right Trigger | Actions |
Attack2 | Mouse2 | Left Trigger | Actions |
Reload | R | X Button | Actions |
Use | E | Y Button | Actions |
Slot1–Slot9 | 1–9 | D-Pad | Inventory |
SlotNext | Mouse5 | Right Bumper | Inventory |
SlotPrev | Mouse4 | Left Bumper | Inventory |
View | C | Right Joystick | Misc |
Voice | V | — | Misc |
Flashlight | F | D-Pad North | Misc |
Defining custom actions
Open your project’s Input Settings asset in the editor and add entries. EachInputAction has:
- Name — alphanumeric identifier (no spaces). Used in code:
Input.Down( "Sprint" ). - GroupName — category for the binding UI.
- Title — optional friendly name shown in the UI.
- KeyboardCode — key or mouse button string (e.g.
"shift","mouse1"). - GamepadCode — a
GamepadCodeenum value.
Querying actions
All three query methods accept an action name string and return abool. They must be called from a component’s OnUpdate (or another per-frame method).
Input.Down
Returnstrue while the action is held.
Input.Pressed
Returnstrue on the frame the action transitions from not-pressed to pressed (rising edge). Use this for single-trigger events like jumping or opening a menu.
Input.Released
Returnstrue on the frame the action transitions from pressed to not-pressed (falling edge).
All three methods return
false on dedicated servers and when input is suppressed (e.g. a UI element has captured focus). You do not need to guard against server-side calls manually.Suppressing input
If you want to prevent all input queries from returningtrue (for example, when a UI overlay is open), set Input.Suppressed = true for that frame. All Down, Pressed, Released, MouseDelta, MouseWheel, and AnalogLook calls return their zero/default values while suppressed.
Mouse input
MouseDelta
Input.MouseDelta is a Vector2 representing how far the mouse moved since the last frame, in screen pixels. The engine accumulates raw OS mouse movement and resets it each frame.
MouseWheel
Input.MouseWheel is a Vector2 representing scroll input. The y component is the standard vertical scroll wheel.
AnalogLook
Input.AnalogLook is an Angles value pre-scaled by Preferences.Sensitivity. It is automatically zeroed when the mouse cursor is visible. This is the preferred value to use for camera look logic:
AnalogMove
Input.AnalogMove is a Vector3 built from the Forward, Backward, Left, and Right actions. It combines keyboard WASD with controller left-stick input automatically.
Gamepad support
The engine detects whether the last input event came from a gamepad and exposes this viaInput.UsingController. You can branch your UI hints on this value.
Input.GetButtonOrigin( string actionName ) returns the human-readable key or button name for the given action, accounting for the current input device.
Programmatic action control
You can set, clear, and release actions from code — useful for AI controllers or testing:VR input
VR-specific input is available throughInput.VR, which returns the VRInput.Current singleton. Use this for hand tracking, trigger values, and pose data on supported runtimes (SteamVR, OpenXR).
VR input is only meaningful when the game is running in a VR headset. On non-VR clients,
Input.VR returns a default VRInput with all values at zero.Motion sensor input
Controllers that expose a motion sensor (DualShock 4+, Switch controllers, Steam Controller, Steam Deck) provide orientation data viaInput.MotionData:
Scripting basics
Lifecycle methods and where to call input queries.
Action Graphs
Wire input nodes visually with the Action Graph editor.
Input API reference
Full static API for the Input class.
Character controller
Applying AnalogMove and AnalogLook to a character.