Skip to main content

Documentation 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.

The Input static class is the primary way to read player input in s&box. It provides action-based queries (Down, Pressed, Released), analog values for movement and camera look, raw mouse and wheel deltas, direct keyboard key queries via Input.Keyboard, and VR controller data via Input.VR.
All input queries return false or default when Input.Suppressed is true (e.g. when a UI panel has focus) or when running headless.

Action queries

Actions are named bindings defined in the game’s Input Settings asset. The default action set covers common gameplay verbs. Use the action name string to query state.
Input.Down(string action)
bool
Returns true while the action is held. Call this every tick to check a continuous hold.
Input.Pressed(string action)
bool
Returns true on the first tick the action transitions from released to held — i.e. the press edge. Use this for one-shot events like firing a weapon.
Input.Released(string action)
bool
Returns true on the first tick the action transitions from held to released — the release edge.
Input.SetAction(string action, bool down)
void
Programmatically activates or deactivates an action. Useful for AI or replay systems that synthesize input.
Input.Clear(string action)
void
Clears a single action so it is no longer considered pressed. Equivalent to SetAction( action, false ).
Input.ClearActions()
void
Clears all current and previous action states so no actions are active this tick.
Input.ReleaseActions()
void
Releases all actions and resets accumulated press state. Unlike ClearActions, the actions will not re-activate until the player physically presses them again.
Input.ReleaseAction(string name)
void
Releases a single action and resets its accumulated press state.

Default actions

Games that do not define a custom input settings asset receive the following defaults:
GroupActionDefault KeyGamepad
MovementForwardW
MovementBackwardS
MovementLeftA
MovementRightD
MovementJumpSpaceA Button
MovementRunShiftLeft Stick Click
MovementWalkAlt
MovementDuckCtrlB Button
ActionsAttack1Mouse1Right Trigger
ActionsAttack2Mouse2Left Trigger
ActionsReloadRX Button
ActionsUseEY Button
InventorySlot1Slot01–0D-pad
InventorySlotPrev / SlotNextMouse4 / Mouse5Bumpers
MiscViewCRight Stick Click
MiscVoiceV
MiscDropG
MiscFlashlightFD-pad Up
MiscScoreTabLeft Menu
MiscMenuQRight Menu
MiscChatEnter

Analog values

Input.AnalogLook
Angles
The look delta for this tick, already scaled by Preferences.Sensitivity. Pitch and yaw are non-zero only when the mouse cursor is hidden. Respect Preferences.InvertMousePitch and Preferences.InvertMouseYaw — these are applied automatically.Write to this property inside a BuildInput override to override the look value before it is consumed by the camera.
Input.AnalogMove
Vector3
A unit movement vector derived from the Forward, Backward, Left, and Right actions plus any analog gamepad joystick input. Components are in the range [-1, 1].Write to this property to override movement direction.
Input.MouseDelta
Vector2
Raw mouse movement in pixels since the last frame. Not sensitivity-scaled. Use AnalogLook for a sensitivity-corrected look delta.
Input.MouseWheel
Vector2
Scroll wheel delta. Y is the primary scroll axis; X is horizontal scroll.
Input.MouseCursorVisible
bool
true when the OS cursor is visible, typically because a UI panel has focus. When true, AnalogLook is zeroed automatically.
Input.MotionData
InputMotionData
Motion sensor data (gyroscope/accelerometer) from supported controllers: DualShock 4+, Nintendo Switch controllers, Steam Controller, and Steam Deck. Check whether the current controller supports motion before relying on this value.

Controller state

Input.UsingController
bool
Returns true when the most recent button press came from a gamepad rather than a keyboard or mouse. Use this to switch HUD prompts between keyboard and controller glyphs.
Input.EscapePressed
bool
true when Escape was pressed this frame. You can set this to false to consume the event and prevent the default menu toggle.
Input.VR
VRInput
Access to VR-specific controller input. Returns VRInput.Current.

Action discovery

Input.ActionNames
IEnumerable<string>
All action names registered by the current game’s input settings.
Input.GetActions()
IEnumerable<InputAction>
Returns a copy of all registered InputAction definitions including their name, keyboard code, and gamepad code.
Input.GetGroupName(string action)
string
Returns the group name (e.g. "Movement", "Actions") for the given action name.
Input.GetButtonOrigin(string name, bool ignoreController)
string
Returns the user-facing label for the button bound to the given action. Returns the gamepad button name when a controller is active, otherwise the local keyboard key name (e.g. "SPACE" or "A Button").

Input.Keyboard

Input.Keyboard lets you query raw physical key state independently of the action system. Use it when you need to detect a specific key that is not mapped to a game action.
Input.Keyboard.Down(string keyName)
bool
Returns true while the physical key is held. keyName is a string like "space", "a", "ctrl", or "mouse1".
Input.Keyboard.Pressed(string keyName)
bool
Returns true on the first tick the key transitions from released to held.
Input.Keyboard.Released(string keyName)
bool
Returns true on the first tick the key transitions from held to released.

Usage examples

protected override void OnUpdate()
{
    // One-shot jump
    if ( Input.Pressed( "Jump" ) )
    {
        ApplyJumpImpulse();
    }

    // Continuous crouch hold
    if ( Input.Down( "Duck" ) )
    {
        SetCrouch( true );
    }

    // Release event
    if ( Input.Released( "Duck" ) )
    {
        SetCrouch( false );
    }
}

Input guide

How to set up input actions, custom bindings, and action graphs.

Game class

Global game state including IsEditor and session management.

Build docs developers (and LLMs) love