Input class inside any component to check which buttons are pressed, read analog stick values, and respond to player actions. Input actions are named strings (like "jump") that map to keys you configure in Project Settings, so players can rebind them without any code changes.
Reading button state
Call these methods insideOnUpdate() to react to input each frame:
| Method | When it returns true |
|---|---|
Input.Down( "action" ) | The button is held down this frame |
Input.Pressed( "action" ) | The button was just pressed this frame |
Input.Released( "action" ) | The button was just released this frame |
Analog inputs
Use these properties to read directional and look input, which automatically maps to both keyboard/mouse and gamepad sticks:Custom key bindings
Define your game’s input actions in Project Settings → Input. Each action maps a name like"jump" to one or more keys. Players can rebind actions through the standard s&box settings menu.
Input action names are case-insensitive, so
"Jump" and "jump" refer to the same action.Escape key
By default, s&box shows its pause menu when the player presses Escape. You can intercept it and handle it yourself:Controller input
Detecting controller use
Reading analog axes directly
Haptics and rumble
Trigger rumble with precise motor values:Input.StopAllHaptics().
Motion controls
If the controller has a gyroscope or accelerometer:Local multiplayer
Scope input queries to a specific controller index to support multiple local players:Input glyphs
Display the correct button icon for the player’s current device. Glyphs update automatically when players rebind keys or switch input devices, so fetch them each frame:<Image> element:
Raw keyboard input
You can bypass the action system and query physical keys directly:Full raw key name reference
Full raw key name reference
| Key string | Key |
|---|---|
"0" – "9" | 0–9 |
"a" – "z" | A–Z |
"KP_0" – "KP_9" | Numpad 0–9 |
"KP_DIVIDE" | Numpad / |
"KP_MULTIPLY" | Numpad * |
"KP_MINUS" | Numpad - |
"KP_PLUS" | Numpad + |
"KP_ENTER" | Numpad Enter |
"KP_DEL" | Numpad Delete |
"ENTER" | Enter |
"SPACE" | Space |
"BACKSPACE" | Backspace |
"TAB" | Tab |
"CAPSLOCK" | Caps Lock |
"NUMLOCK" | Num Lock |
"ESCAPE" | Escape |
"SCROLLLOCK" | Scroll Lock |
"INS" | Insert |
"DEL" | Delete |
"HOME" | Home |
"END" | End |
"PGUP" | Page Up |
"PGDN" | Page Down |
"PAUSE" | Pause |
"SHIFT" | Left Shift |
"RSHIFT" | Right Shift |
"ALT" | Left Alt |
"RALT" | Right Alt |
"UPARROW" | Up Arrow |
"LEFTARROW" | Left Arrow |
"RIGHTARROW" | Right Arrow |
"DOWNARROW" | Down Arrow |
"SEMICOLON" | Semicolon |
"<" | Less Than |
">" | More Than |
"[" | Left Bracket |
"]" | Right Bracket |
"," | Comma |
"." | Period |
"/" | Slash |
"\\" | Backslash |
"-" | Hyphen / Minus |
"=" | Equals |
"`" | Backtick / Console key |
"'" | Apostrophe |