menu_bookDocumentation

s&box Input System: Down, Pressed, Released, AnalogLook, AnalogMove, Input Contexts, and Suppression

calendar_today May 4, 2026 schedule ~1 min read person patrickjr verified 50

s&box Input System: Actions, Contexts, and How Input State Works

The s&box Input static class provides all player input querying. Actions are defined in the project's InputSettings and referenced by name string.

Querying Input

CSHARP
Input.Down( "attack" )      // true while the action is held
Input.Pressed( "attack" )   // true on the frame the action was first pressed
Input.Released( "attack" )  // true on the frame the action was released

Input.AnalogLook            // Angles — mouse/stick look delta, scaled by Preferences.Sensitivity
Input.AnalogMove            // Vector3 — WASD/stick movement direction
Input.MouseDelta            // Vector2 — raw mouse movement delta
Input.MouseWheel            // Vector2 — mouse wheel delta
Input.UsingController       // bool — last input was from a gamepad
Input.Suppressed            // bool — when true, all input returns default/false

How Actions Work Internally

Actions are packed into a ulong bitmask (up to 64 actions). Each action has an index determined by its position in InputSettings.Actions. Input.Down checks (Actions & 1UL << index) != 0.

Input Contexts

Input.Context allows frame and fixed-update tick to have independent input state. Each context accumulates input events and is "flipped" at the start of its period. The scene creates a FixedUpdateInputContext that is flipped at the start of each fixed update, so Input.Pressed works correctly inside OnFixedUpdate — you won't miss presses that happened between ticks.
CSHARP
// Create a context (e.g., for a custom tick)
var ctx = Input.Context.Create( "MyContext" );

// Push it as the active context for a scope
using ( ctx.Push() )
{
    ctx.Flip(); // Snapshot accumulated input into current/previous state
    // Input.Down etc. now reads from this context
}

Suppressing Input

CSHARP
Input.Suppressed = true;  // All Input.Down/Pressed/Released return false

Useful for UI focus, cutscenes, or any time you want to block game input without removing bindings.

Programmatic Input

CSHARP
Input.SetAction( "attack", true );   // Simulate pressing an action
Input.Clear( "attack" );             // Release an action
Input.ClearActions();                // Release all actions (but they can be re-pressed)
Input.ReleaseActions();              // Release all actions and prevent re-press until physical input
Input.ReleaseAction( "attack" );     // Release a specific action and prevent re-press

AnalogMove is Built from WASD

AnalogMove is computed from the forward, backward, left, right actions each frame — it is not a raw analog value from a stick unless controller input overrides it via ProcessControllerInput().

Input on Dedicated Server

Input.Down, Input.Pressed, Input.Released all return false when Application.IsHeadless is true. Input is client-only in s&box.
Was this helpful?