Input

Every game needs to receive user input for players to interact and view their environment. Roblox supports nearly all forms of input, including mouse/keyboard, touch, gamepads, and VR.

Cross-platform input

Roblox is inherently cross‑platform, as players can discover and join games on their phone or tablet, then later continue where they left off on their PC or console. Input is especially important as part of your cross‑platform development plan.

To simplify this process, Roblox provides the Input Action System to define actions such as "jump," "sprint," or "shoot" and set up bindings for multiple hardware inputs to drive those actions. This frees you from thinking of all the technical aspects of hardware inputs and allows you to simply define which inputs perform which actions.

Input type detection

In cross‑platform development, it's important that you determine and respond to the primary input type a player is using, normally to ensure that UI elements like on‑screen buttons and menus work elegantly across devices.

For example, a touch‑enabled device assumes touch is the default input and that touch buttons may appear for actions, but if a player connects an additional bluetooth keyboard/mouse or gamepad, you can assume they want to switch to that as the primary input type and possibly use touch as a backup input for on‑screen UI. The read‑only UserInputService.PreferredInput property is a convenient way to test for and adapt to multiple input types across multiple device types, based on anticipated player behavior.

The value of PreferredInput changes based on built‑in device inputs and the player's most recent interaction with a connected gamepad or keyboard/mouse. Examples include:

Real-World ScenarioPreferredInput
Player is using a phone with no other connected input devices; no possibility of an input type change.Touch
Player is using a mobile device with a bluetooth keyboard & mouse connected, but no gamepad is connected.KeyboardAndMouse
Player is using a tablet with a bluetooth gamepad connected, but no keyboard or mouse is connected.Gamepad
Player is using an Xbox or PlayStation with a bluetooth keyboard & mouse connected and has most recently interacted with the keyboard or mouse.KeyboardAndMouse
Player is on a Windows or Mac PC with a gamepad connected and has most recently interacted with the gamepad.Gamepad

The following LocalScript is a template for initially detecting the preferred input and responding to changes during gameplay.

PreferredInput detection

local UserInputService = game:GetService("UserInputService")
local function preferredInputChanged()
local preferredInput = UserInputService.PreferredInput
if preferredInput == Enum.PreferredInput.Touch then
-- Player is on touch-enabled device with no other input types available/connected
print("Touch")
elseif preferredInput == Enum.PreferredInput.Gamepad then
-- Player has connected or most recently interacted with a gamepad
print("Gamepad")
elseif preferredInput == Enum.PreferredInput.KeyboardAndMouse then
-- Player has connected or most recently interacted with a keyboard or mouse
print("KeyboardAndMouse")
end
end
preferredInputChanged()
UserInputService:GetPropertyChangedSignal("PreferredInput"):Connect(function()
preferredInputChanged()
end)

Default bindings

Roblox provides default input bindings for movement, camera control, and basic environment interaction — Roblox players are familiar with these controls, so you should only override them in specific cases. Also note that the reserved inputs cannot be overridden and will always operate with their intended purpose.

ActionMouse/KeyboardGamepadTouch
Open Roblox menuEscStart button (ButtonStart)N/A
Developer ConsoleF9N/AN/A
Fullscreen mode (Windows)
Show desktop (Mac)
F11N/AN/A
Record video (Windows)F12N/AN/A
Take screenshotPrintScreenN/AN/A
©2026 Roblox Corporation. Roblox, the Roblox logo and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.