Common input tasks
Find the instructions for common input tasks, grouped by topic.
If you're new to the Input System, start with the Quickstart Guide, and the Concepts and Workflows pages. The Input System offers several ways to read input, and some pages linked here describe the quickest approach, which might not suit a project with more complex requirements.
Read input from devices
| Task | Instructions |
|---|---|
| Check whether the user pressed a key or button this frame | Read devices directly |
| Check whether the user pressed any key or button | InputSystem.onAnyButtonPress |
| Get the mouse or pointer position | Query and control mouse devices in code |
| Get all current touches from the touchscreen | Read all touches |
| Detect which GameObject the user clicks or touches | Detect clicks and touches on GameObjects |
Find and manage devices
| Task | Instructions |
|---|---|
| Find all connected gamepads | Discover all connected devices |
| Find the device a player is using, for example to show matching button prompts | Find the device a player is using |
| Find out when the user connects or disconnects a device | Monitor devices |
| Add a deadzone to gamepad sticks | Add a deadzone to a gamepad |
| Check which devices are connected, and their state | Debug a device |
Set up actions and bindings
| Task | Instructions |
|---|---|
| Create a simple action, such as Fire | Actions workflow. Use the same technique as the Jump action. |
| Make an action trigger only after the user holds a button for some time | Hold interaction |
| Use a positive and a negative button to drive an axis | 1D axis |
| Let players rebind their controls | Interactive rebinding |
| Display the name or icon of the control bound to an action | Display bindings |
Create custom devices and layouts
| Task | Instructions |
|---|---|
| Create your own custom device | Create a custom device layout |
Handle gamepad data in a format different from GamepadState |
GamepadState |
| Use your own layout when the native backend discovers a specific device | Native devices |
Work with XR devices
| Task | Instructions |
|---|---|
| Set up an action that targets only the left-hand XR controller | XRController |
| Make the left-hand XR controller act as the right-hand one | XRController |
| Give head tracking an extra update before rendering | XRHMD |
Debug input
| Task | Instructions |
|---|---|
| Record the events that flow through the Input System | See and record input event flow |
| Watch events as the Input System processes them | See and record input event flow |