Input static class is the primary way to query player input. It works through named actions — logical bindings that map hardware buttons to string identifiers. Actions are defined in the project’s input settings and are available in-game via Input.Pressed, Input.Down, and Input.Released.
Read input in
OnUpdate (or OnFixedUpdate for physics-driven movement). Input state is only valid during the game tick — do not read it from background threads.Action queries
Input.Pressed
Returns
true on the first tick the action transitions from not-held to held. Use for one-shot events like firing a weapon or opening a menu.Input.Down
Returns
true every tick the action is currently held down. Use for continuous actions like moving or charging.Input.Released
Returns
true on the first tick the action transitions from held to not-held. Use for release events.Input.SetAction
Manually override an action’s state. Useful for simulated input in bots or tutorials.Input.Clear and ReleaseAction
Mouse
MouseDelta
Pixel delta of the mouse since the last tick. Only non-zero when the cursor is captured (not visible).
MouseWheel
Mouse wheel scroll delta this tick.
y is the vertical scroll; x is horizontal tilt on supported devices.MouseCursorVisible
true when the cursor is visible (the player is interacting with UI). When true, AnalogLook is zeroed out.Analog inputs
AnalogLook
Rotational input from the mouse (or right joystick on a gamepad), pre-scaled by
Preferences.Sensitivity. pitch is vertical look, yaw is horizontal look. Use this to drive camera and character rotation.AnalogMove
Directional movement input assembled from the
Forward, Backward, Left, and Right actions, or from the gamepad left joystick. Axes are x (forward/backward), y (left/right), z (up/down). Values are in the range [-1, 1] per axis.Keyboard (raw key queries)
UseInput.Keyboard for direct key-by-key queries when you need to bypass the action system. This is useful for editor tooling or text input handling.
Input.Keyboard.Down
Returns
true every tick the specified key is physically held.Input.Keyboard.Pressed
Returns
true on the first tick the key transitions to held.Input.Keyboard.Released
Returns
true on the first tick the key transitions to released.Other helpers
EscapePressed
UsingController
true when the last input event came from a gamepad. Use this to switch between keyboard and controller UI hints.GetButtonOrigin
Returns the display name of the key or button bound to an action.GetActions / ActionNames
InputAction
InputAction defines a named binding with a keyboard key, a gamepad button, a group, and a display title. Actions are declared in the project’s Input Settings asset.
Properties
Identifier used with
Input.Pressed, Input.Down, and Input.Released. Alphanumeric and underscores only, no spaces.The default keyboard key or key combo (e.g.
"space", "mouse1", "ctrl+z").The default gamepad button mapping (e.g.
GamepadCode.A, GamepadCode.RightTrigger).Category shown in the key-binding UI. Defaults to
"Other".Human-readable display name shown in the key-binding UI. Falls back to
Name if not set.Built-in actions
The engine ships default actions that are available in every game unless you override them:| Name | Default key | Gamepad | Group |
|---|---|---|---|
Forward | W | — | Movement |
Backward | S | — | Movement |
Left | A | — | Movement |
Right | D | — | Movement |
Jump | space | A | Movement |
Run | shift | Left stick click | Movement |
Duck | ctrl | B | Movement |
Attack1 | mouse1 | Right Trigger | Actions |
Attack2 | mouse2 | Left Trigger | Actions |
Reload | R | X | Actions |
Use | E | Y | Actions |