Reference API Roblox

Engine API

Website

Related

Reference API Roblox

UserInputService

UserInputService is primarily used to detect the input types available on a user's device, as well as detect input events.

This class is not replicated. Its interface does not cross the network boundary.
This class is not creatable. Instances of this class cannot be created with Instance.new.
This class is a service. It is a singleton that may be acquired with GetService.
Tags: [NotCreatable, Service, NotReplicated]

Member index 81

HistoryMember
553AccelerometerEnabled: bool
553GamepadEnabled: bool
553GyroscopeEnabled: bool
553KeyboardEnabled: bool
553ModalEnabled: bool
553MouseBehavior: MouseBehavior
553MouseDeltaSensitivity: float
553MouseEnabled: bool
645MouseIcon: ContentId
553MouseIconEnabled: bool
553OnScreenKeyboardPosition: Vector2
553OnScreenKeyboardSize: Vector2
553OnScreenKeyboardVisible: bool
675PreferredInput: PreferredInput
553TouchEnabled: bool
553UserHeadCFrame: CFrame
553VREnabled: bool
462GamepadSupports(gamepadNum: UserInputType, gamepadKeyCode: KeyCode): bool
462GetConnectedGamepads(): Array
483GetDeviceAcceleration(): InputObject
483GetDeviceGravity(): InputObject
638GetDeviceLevel(): DeviceLevel
462GetDeviceRotation(): Tuple
462GetDeviceType(): DeviceType
483GetFocusedTextBox(): TextBox
462GetGamepadConnected(gamepadNum: UserInputType): bool
462GetGamepadState(gamepadNum: UserInputType): Array
645GetImageForKeyCode(keyCode: KeyCode): ContentId
462GetKeysPressed(): Array
462GetLastInputType(): UserInputType
462GetMouseButtonsPressed(): Array
462GetMouseDelta(): Vector2
462GetMouseLocation(): Vector2
462GetNavigationGamepads(): Array
672GetPasteText(): string
462GetPlatform(): Platform
462GetStringForKeyCode(keyCode: KeyCode): string
462GetSupportedGamepadKeyCodes(gamepadNum: UserInputType): Array
605GetUserCFrame(type: UserCFrame): CFrame
462IsGamepadButtonDown(gamepadNum: UserInputType, gamepadKeyCode: KeyCode): bool
462IsKeyDown(keyCode: KeyCode): bool
462IsMouseButtonPressed(mouseButton: UserInputType): bool
462IsNavigationGamepad(gamepadEnum: UserInputType): bool
573RecenterUserHeadCFrame(): null
573SendAppUISizes(statusBarSize: Vector2, navBarSize: Vector2, bottomBarSize: Vector2, rightBarSize: Vector2): null
573SetNavigationGamepad(gamepadEnum: UserInputType, enabled: bool): null
483DeviceAccelerationChanged(acceleration: InputObject)
483DeviceGravityChanged(gravity: InputObject)
483DeviceRotationChanged(rotation: InputObject, cframe: CFrame)
462GamepadConnected(gamepadNum: UserInputType)
462GamepadDisconnected(gamepadNum: UserInputType)
483InputBegan(input: InputObject, gameProcessedEvent: bool)
483InputChanged(input: InputObject, gameProcessedEvent: bool)
483InputEnded(input: InputObject, gameProcessedEvent: bool)
462JumpRequest()
462LastInputTypeChanged(lastInputType: UserInputType)
462PointerAction(wheel: float, pan: Vector2, pinch: float, gameProcessedEvent: bool)
462StatusBarTapped(position: Vector2)
483TextBoxFocusReleased(textboxReleased: TextBox)
483TextBoxFocused(textboxFocused: TextBox)
650TouchDrag(dragDirection: SwipeDirection, numberOfTouches: int, gameProcessedEvent: bool)
483TouchEnded(touch: InputObject, gameProcessedEvent: bool)
462TouchLongPress(touchPositions: Array, state: UserInputState, gameProcessedEvent: bool)
483TouchMoved(touch: InputObject, gameProcessedEvent: bool)
462TouchPan(touchPositions: Array, totalTranslation: Vector2, velocity: Vector2, state: UserInputState, gameProcessedEvent: bool)
462TouchPinch(touchPositions: Array, scale: float, velocity: float, state: UserInputState, gameProcessedEvent: bool)
462TouchRotate(touchPositions: Array, rotation: float, velocity: float, state: UserInputState, gameProcessedEvent: bool)
483TouchStarted(touch: InputObject, gameProcessedEvent: bool)
462TouchSwipe(swipeDirection: SwipeDirection, numberOfTouches: int, gameProcessedEvent: bool)
462TouchTap(touchPositions: Array, gameProcessedEvent: bool)
462TouchTapInWorld(position: Vector2, processedByUI: bool)
605UserCFrameChanged(type: UserCFrame, value: CFrame)
462WindowFocusReleased()
462WindowFocused()
inherited from Instance
553Archivable: bool
670Capabilities: SecurityCapabilities
553Name: string
553Parent: Instance
670Sandboxed: bool
680UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
486GetDescendants(): Array
486GetFullName(): string
641GetStyled(name: string): Variant
657GetStyledPropertyChangedSignal(property: string): RBXScriptSignal
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
664IsPropertyModified(property: string): bool
573Remove(): null
576RemoveTag(tag: string): null
664ResetPropertyToDefault(property: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
648children(): Instances
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
648getChildren(): Instances
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
657StyledPropertiesChanged()
553childAdded(child: Instance)
inherited from Object
647ClassName: string
647className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
650isA(className: string): bool
647Changed(property: string)

Removed member index 10

HistoryMember
220InCameraGesture: bool
240IsVREnabled: bool
220OverrideMouseIconEnabled: bool
118TouchControlsEnabled: bool
230IsLuaTouchControls(): bool
230IsStudioTouchEmulationEnabled(): bool
230RotateCamera(positionDelta: Vector2): void
230ZoomCamera(zoomDelta: float): void
230ProcessedEvent(inputObject: Instance, processed: bool)

Description

UserInputService is primarily used to detect the input types available on a user's device, as well as detect input events. It allows you to perform different actions depending on the device and, in turn, provide the best experience for the end user.

As this service is intended for client-side usage only, its properties, methods, and events can only be used in a LocalScript, a ModuleScript required by a LocalScript, or a Script with RunContext set to RunContext.Client.

History 326

Members 81

AccelerometerEnabled

TypeDefault
bool

This property describes whether the user's device has an accelerometer, a component found in most mobile devices that measures acceleration (change in speed).

If the device has an enabled accelerometer, you can get its current acceleration by using the GetDeviceAcceleration() method or track when the device's acceleration changes through the DeviceAccelerationChanged event.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 4

Tags: [ReadOnly, NotReplicated]

DeviceAccelerationChanged

Parameters (1)
accelerationInputObject

This event fires when a user moves a device that has an accelerometer, a component found in most mobile devices that measures acceleration (change in speed). To determine whether a user's device has an accelerometer enabled, use AccelerometerEnabled.

This event can be used along with GetDeviceAcceleration() to determine the current movement of a user's device.

History 3

DeviceGravityChanged

Parameters (1)
gravityInputObject

This event fires when the device's gravity Vector3 changes on a device that has an accelerometer. To determine whether a user's device has an accelerometer enabled, use AccelerometerEnabled.

A device's gravity vector represent the force of gravity on each of the device's X, Y, and Z axes. While gravity never changes, the force it exerts on each axis changes when the device rotates and changes orientation. The force value exerted on each axis is a unit vector ranging from -1 to 1.

If the device has an enabled accelerometer, you can use the GetDeviceGravity() method to get the current force of gravity on the user's device.

History 3

DeviceRotationChanged

Parameters (2)
rotationInputObject
cframeCFrame

This event fires when a user rotates a device that has a gyroscope, a component found in most mobile devices that detects orientation and rotational speed. To check if a user's device has an enabled gyroscope, use GyroscopeEnabled.

To query the current device rotation, use the GetDeviceRotation() method.

Note that this event only fires when the Roblox client window is in focus. Inputs will not be captured when the window is minimized.

History 3

GamepadConnected

Parameters (1)
gamepadNumUserInputType

This event fires when a gamepad is connected to the client. You can also use GetConnectedGamepads() to find the correct gamepad to use.

Alternatively, you can detect value changes to the PreferredInput property which more accurately reflects which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.

See also GamepadDisconnected.

History 2

GamepadDisconnected

Parameters (1)
gamepadNumUserInputType

This event fires when a gamepad is disconnected from the client.

Alternatively, you can detect value changes to the PreferredInput property which more accurately reflects which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.

See also GamepadConnected.

History 2

GamepadEnabled

TypeDefault
bool

This property describes whether the user's device has an available gamepad. If true, you can use gamepad‑related methods such as GetConnectedGamepads().

For seamless cross-platform compatibility on mixed-input devices, see PreferredInput which more accurately reflects which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 6

Tags: [ReadOnly, NotReplicated]

GamepadSupports

Parameters (2)
gamepadNumUserInputType
gamepadKeyCodeKeyCode
Returns (1)
bool

This method returns whether the given UserInputType gamepad supports a button corresponding with the given KeyCode.

History 2

GetConnectedGamepads

Parameters (0)
No parameters.
Returns (1)
Array

This method returns an array of UserInputType gamepads currently connected. If no gamepads are connected, the array will be empty.

Alternatively to detecting all gamepads, the PreferredInput property can be used to more accurately reflect which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.

History 2

GetDeviceAcceleration

Parameters (0)
No parameters.
Returns (1)
InputObject

This method returns an InputObject that describes the device's current acceleration. For this to function, the user's device must have an enabled accelerometer as queried through the AccelerometerEnabled property.

To track when the device's acceleration changes, use the DeviceAccelerationChanged event.

History 3

GetDeviceGravity

Parameters (0)
No parameters.
Returns (1)
InputObject

This method returns an InputObject describing the device's current gravity vector. The vector is determined by the device's orientation relative to the real-world force of gravity. For example:

Gravity is only tracked for devices with an enabled gyroscope as queried through GyroscopeEnabled.

To track when the device's gravity changes, use the DeviceGravityChanged event.

History 3

GetDeviceLevel

Parameters (0)
No parameters.
Returns (1)
DeviceLevel

History 1

GetDeviceRotation

Parameters (0)
No parameters.
Returns (1)
Tuple

This method returns an InputObject and a CFrame describing the device's current rotation vector.

Device rotation is only tracked for devices with an enabled gyroscope as queried through GyroscopeEnabled.

History 2

GetDeviceType

Parameters (0)
No parameters.
Returns (1)
DeviceType

History 2

GetFocusedTextBox

Parameters (0)
No parameters.
Returns (1)
TextBox

This method returns the TextBox the client is currently focused on. A TextBox can be manually selected by the user, or selection can be forced using the TextBox:CaptureFocus() method. If no TextBox is selected, this method will return nil.

History 3

GetGamepadConnected

Parameters (1)
gamepadNumUserInputType
Returns (1)
bool

This method returns whether a gamepad with the given UserInputType is connected.

Alternatively to detecting a specific gamepad by UserInputType, the PreferredInput property can be used to more accurately reflect which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.

History 2

GetGamepadState

Parameters (1)
gamepadNumUserInputType
Returns (1)
Array

This method returns an array of InputObjects for all available inputs on the given UserInputType gamepad, representing each input's last input state.

History 2

GetImageForKeyCode

Parameters (1)
keyCodeKeyCode
Returns (1)
ContentId

This method takes the requested KeyCode and returns the associated image for the currently connected gamepad device (limited to Xbox, PlayStation, and Windows). This means that if the connected controller is an Xbox One controller, the user sees Xbox assets. Similarly, if the connected device is a PlayStation controller, the user sees PlayStation assets. If you want to use custom assets, see GetStringForKeyCode().

History 2

GetKeysPressed

Parameters (0)
No parameters.
Returns (1)
Array

This method returns an array of InputObjects associated with the keys currently being pressed down. The array can be iterated through to determine which keys are currently being pressed, using the InputObject.KeyCode names or values.

To check if a specific key is being pressed, use IsKeyDown().

History 4

GetLastInputType

Parameters (0)
No parameters.
Returns (1)
UserInputType

This method returns the UserInputType associated with the user's most recent input. For example, if the user's previous input had been pressing the A key, the returned UserInputType value would be Keyboard.

For seamless cross-platform compatibility on mixed-input devices, see PreferredInput which more accurately reflects which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input. GetLastInputType() remains for advanced workflows or control schemes that rely on detecting and responding to the player's specific most recent UserInputType.

History 3

GetMouseButtonsPressed

Parameters (0)
No parameters.
Returns (1)
Array

This method returns an array of InputObjects associated with the mouse buttons currently being held down. The array can be iterated through to determine which buttons are currently being held, using the InputObject.KeyCode names or values.

Mouse buttons that are tracked by this method include MouseButton1 (left), MouseButton2 (right), and MouseButton3 (middle).

If the user is not pressing any mouse button down when the method is called, it will return an empty array.

History 2

GetMouseDelta

Parameters (0)
No parameters.
Returns (1)
Vector2

This method returns the change, in pixels, of the position of the player's Mouse in the last rendered frame, only if the mouse has been locked using the MouseBehavior property; otherwise the returned Vector2 values will be 0.

The sensitivity of the mouse, determined in the client's settings and MouseDeltaSensitivity, will influence the result.

History 2

GetMouseLocation

Parameters (0)
No parameters.
Returns (1)
Vector2

This method returns a Vector2 representing the current screen location of the player's Mouse in pixels relative to the top‑left corner. This does not account for the ScreenInsets; to get the top‑left and bottom‑right insets, call GuiService:GetGuiInset().

If the location of the mouse pointer is offscreen or the player's device does not have a mouse, the returned value will be undetermined.

History 2

GetNavigationGamepads

Parameters (0)
No parameters.
Returns (1)
Array

This method returns an array of gamepads that are connected and enabled for GuiObject navigation, but does not influence navigation controls. This list is in descending order of priority, meaning it can be iterated over to determine which gamepad should have navigation control.

See also SetNavigationGamepad(), IsNavigationGamepad(), and GetConnectedGamepads().

History 2

GetPasteText

Parameters (0)
No parameters.
Returns (1)
string

History 1

GetPlatform

Parameters (0)
No parameters.
Returns (1)
Platform

History 2

GetStringForKeyCode

Parameters (1)
keyCodeKeyCode
Returns (1)
string

This method returns a string representing a key the user should press in order to input a given KeyCode, keeping in mind their keyboard layout. For key codes that require some modifier to be held, this method returns the key to be pressed in addition to the modifier. See the examples below for further explanation.

When using Roblox with a non‑QWERTY keyboard layout, key codes are mapped to equivalent QWERTY positions. For example, pressing A on an AZERTY keyboard results in KeyCode.Q, potentially leading to mismatched information on experience UI elements. This method solves the issue by providing the actual key to be pressed while using non‑QWERTY keyboard layouts.

KeyCodeQWERTY ReturnAZERTY Return
KeyCode.QQA
KeyCode.WWZ
KeyCode.Equals==
KeyCode.At2 because @ is typed with Shift2É

Gamepad Usage

GetStringForKeyCode() returns the string mapping for the KeyCode for the most recently connected gamepad. If the connected controller is not supported, the method returns the default string conversion for the requested key code.

The following example shows how you can map custom assets for ButtonA:

local UserInputService = game:GetService("UserInputService")

local imageLabel = script.Parent
local key = Enum.KeyCode.ButtonA

local mappings = {
	ButtonA = "rbxasset://BUTTON_A_ASSET", -- Replace with the desired ButtonA asset
	ButtonCross = "rbxasset://BUTTON_CROSS_ASSET"  -- Replace with the desired ButtonCross asset
}

local mappedKey = UserInputService:GetStringForKeyCode(key)
local image = mappings[mappedKey]

imageLabel.Image = image

Gamepad Mappings

The directional pad key codes do not have any differences based on device. KeyCode.ButtonSelect has slightly different behavior in some cases. Use both PlayStation mappings to ensure users see the correct buttons.

KeyCodePlayStation Return ValueXbox Return Value
KeyCode.ButtonAButtonCrossButtonA
KeyCode.ButtonBButtonCircleButtonB
KeyCode.ButtonXButtonSquareButtonX
KeyCode.ButtonYButtonTriangleButtonY
KeyCode.ButtonL1ButtonL1ButtonLB
KeyCode.ButtonL2ButtonL2ButtonLT
KeyCode.ButtonL3ButtonL3ButtonLS
KeyCode.ButtonR1ButtonR1ButtonRB
KeyCode.ButtonR2ButtonR2ButtonRT
KeyCode.ButtonR3ButtonR3ButtonRS
KeyCode.ButtonStartButtonOptionsButtonStart
KeyCode.ButtonSelectButtonTouchpad and ButtonShareButtonSelect

Legacy System Images

When using a KeyCode that may be better represented as an image, such as for an ImageLabel in a user interface, you can use the following legacy icons. However, it's recommended that you use GetImageForKeyCode() as a more modern, cross‑platform method to retrieve Xbox and PlayStation controller icons.

KeyCodeAsset ID
KeyCode.ButtonXrbxasset://textures/ui/Controls/xboxX.png
KeyCode.ButtonYrbxasset://textures/ui/Controls/xboxY.png
KeyCode.ButtonArbxasset://textures/ui/Controls/xboxA.png
KeyCode.ButtonBrbxasset://textures/ui/Controls/xboxB.png
KeyCode.DPadLeftrbxasset://textures/ui/Controls/dpadLeft.png
KeyCode.DPadRightrbxasset://textures/ui/Controls/dpadRight.png
KeyCode.DPadUprbxasset://textures/ui/Controls/dpadUp.png
KeyCode.DPadDownrbxasset://textures/ui/Controls/dpadDown.png
KeyCode.ButtonSelectrbxasset://textures/ui/Controls/xboxView.png
KeyCode.ButtonStartrbxasset://textures/ui/Controls/xboxmenu.png
KeyCode.ButtonL1rbxasset://textures/ui/Controls/xboxLB.png
KeyCode.ButtonR1rbxasset://textures/ui/Controls/xboxRB.png
KeyCode.ButtonL2rbxasset://textures/ui/Controls/xboxLT.png
KeyCode.ButtonR2rbxasset://textures/ui/Controls/xboxRT.png
KeyCode.ButtonL3rbxasset://textures/ui/Controls/xboxLS.png
KeyCode.ButtonR3rbxasset://textures/ui/Controls/xboxRS.png
KeyCode.Thumbstick1rbxasset://textures/ui/Controls/xboxLSDirectional.png
KeyCode.Thumbstick2rbxasset://textures/ui/Controls/xboxRSDirectional.png
KeyCode.Backspacerbxasset://textures/ui/Controls/backspace.png
KeyCode.Returnrbxasset://textures/ui/Controls/return.png
KeyCode.LeftShiftrbxasset://textures/ui/Controls/shift.png
KeyCode.RightShiftrbxasset://textures/ui/Controls/shift.png
KeyCode.Tabrbxasset://textures/ui/Controls/tab.png
KeyCode.Quoterbxasset://textures/ui/Controls/apostrophe.png
KeyCode.Commarbxasset://textures/ui/Controls/comma.png
KeyCode.Backquoterbxasset://textures/ui/Controls/graveaccent.png
KeyCode.Periodrbxasset://textures/ui/Controls/period.png
KeyCode.Spacerbxasset://textures/ui/Controls/spacebar.png

History 2

GetSupportedGamepadKeyCodes

Parameters (1)
gamepadNumUserInputType
Returns (1)
Array

This method returns an array of KeyCodes that the gamepad associated with the given UserInputType supports. If called on a non‑connected gamepad, returns an empty array.

To determine if a specific KeyCode is supported, use GamepadSupports().

History 2

GetUserCFrame

Parameters (1)
typeUserCFrame
Returns (1)
CFrame

The UserInputService:GetUserCFrame() method returns a CFrame describing the position and orientation of a specified UserCFrame virtual reality (VR) device. If the specified device is not connected, the method returns CFrame.new().

For example, the code snippet below prints the CFrame of the user's VR headset.

1
2
3
4
local UserInputService = game:GetService("UserInputService")
local cframe = UserInputService:GetUserCFrame(Enum.UserCFrame.Head)

print(cframe)

By using the method, players can implement features such as re-positioning the user's in-game character corresponding to the location of a connected VR device. This can be done by changing the CFrame of the user's in-game body parts to match the CFrame of the specified VR device using UserCFrame and CFrame value arguments passed by the event.

See also:

As this event only fires locally, it can only be used in a LocalScript.

This function is deprecated. It exists only for backward compatibility, and should not be used for new work.

History 4

Tags: [Deprecated]

GyroscopeEnabled

TypeDefault
bool

This property describes whether the user's device has a gyroscope, a component found in most mobile devices that detects orientation and rotational speed.

If the device has a gyroscope, you can incorporate it into your experience using the GetDeviceRotation() method or track when the device's rotation changes through the DeviceRotationChanged event.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 4

Tags: [ReadOnly, NotReplicated]

InputBegan

Parameters (2)
inputInputObject
gameProcessedEventbool

This event fires when a user begins interacting with an input device such as a mouse or gamepad, such as when they first interact with a gamepad button, although it does not capture mouse wheel movements. Can be used along with InputChanged and InputEnded to track when user input begins, changes, and ends.

See also InputBinding as a way to hook input device interactions to InputActions.

Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.

History 6

InputChanged

Parameters (2)
inputInputObject
gameProcessedEventbool

This event fires when a user changes how they're interacting with an input device such as a mouse or gamepad. Can be used along with InputBegan and InputEnded to track when user input begins, changes, and ends.

See also InputBinding as a way to hook input device interactions to InputActions.

Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.

History 6

InputEnded

Parameters (2)
inputInputObject
gameProcessedEventbool

This event fires when a user stops interacting with an input device such as a mouse or gamepad, such as when they release a gamepad button. Can be used along with InputBegan and InputChanged to track when user input begins, changes, and ends.

See also InputBinding as a way to hook input device interactions to InputActions.

Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.

History 6

IsGamepadButtonDown

Parameters (2)
gamepadNumUserInputType
gamepadKeyCodeKeyCode
Returns (1)
bool

This method returns true if a particular button is pressed on a gamepad, otherwise returns false.

See also InputBinding as a way to hook gamepad and other input interactions to InputActions.

History 2

IsKeyDown

Parameters (1)
keyCodeKeyCode
Returns (1)
bool

This method returns true if a particular key is pressed on a keyboard, otherwise returns false.

See also InputBinding as a way to hook key and other input interactions to InputActions.

History 4

IsMouseButtonPressed

Parameters (1)
mouseButtonUserInputType
Returns (1)
bool

This method returns true if a particular mouse button is pressed, otherwise returns false.

See also InputBinding as a way to hook mouse button and other input interactions to InputActions.

History 2

IsNavigationGamepad

Parameters (1)
gamepadEnumUserInputType
Returns (1)
bool

This method returns true if the specified gamepad is allowed to control navigation and selection GuiObjects.

Use SetNavigationGamepad() to set a navigation gamepad, or GetNavigationGamepads() to get a list of all navigation gamepads.

History 2

JumpRequest

Parameters (0)
No parameters.

This event fires when there is a jump request from the client, for example when the client presses the spacebar or jump button on mobile. Default behavior is to set the player's Humanoid.Jump property to true which makes the player's character jump.

Since this event fires multiple times for a single jump request, using a debounce is recommended.

History 3

KeyboardEnabled

TypeDefault
bool

This property describes whether the user's device has a keyboard available. If true, you can use key‑related methods such as IsKeyDown() or GetKeysPressed().

For seamless cross-platform compatibility on mixed-input devices, see PreferredInput which more accurately reflects which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 6

Tags: [ReadOnly, NotReplicated]

LastInputTypeChanged

Parameters (1)
lastInputTypeUserInputType

This event fires whenever the client's UserInputType is changed.

To get the value of the last input type, regardless of whether it has changed, use the GetLastInputType() method.

History 3

ModalEnabled

TypeDefault
bool

The ModalEnabled property determines whether character controls are hidden on TouchEnabled devices. By default, this property is false and controls are visible.

This property will only work when used in a LocalScript running for the player whose character controls are to be hidden.

Even if mobile controls are hidden for a player on a touch‑enabled device, other events such as InputBegan and TouchSwipe can still be used to process other forms of input.

This property is deprecated. It exists only for backward compatibility, and should not be used for new work. TouchControlsEnabled should be used instead.

History 6

Tags: [Deprecated]

MouseBehavior

TypeDefault
MouseBehavior

This property sets how the user's mouse behaves based on the MouseBehavior enum. It can be set to three values:

The value of this property does not affect the sensitivity of events tracking mouse movement. For example, GetMouseDelta returns the same Vector2 screen position in pixels regardless of whether the mouse is locked or able to move freely around the user's screen. As a result, default scripts like those controlling the camera are not impacted by this property.

This property is overridden if a GuiButton with Modal enabled is Visible unless the player's right mouse button is down.

Note that if the mouse is locked, InputChanged will still fire when the player moves the mouse and will pass in the delta that the mouse attempted to move by. Additionally, if the player is kicked from the experience, the mouse will be forcefully unlocked.

History 4

MouseDeltaSensitivity

TypeDefault
float

This property determines the sensitivity of the user's Mouse. It can be used to adjust the sensitivity of events tracking mouse movement, such as GetMouseDelta().

This property does not affect the movement of the mouse icon, nor the camera sensitivity that the user has selected for their client.

This property has a maximum value of 10 and a minimum value of 0. When sensitivity is 0, events that track the mouse's movement will still fire but all parameters and properties indicating the change in mouse position will return 0.

This property is not replicated. Its interface does not cross the network boundary.

History 4

Tags: [NotReplicated]

MouseEnabled

TypeDefault
bool

This property describes whether the user's device has a mouse available. If true, you can use mouse‑related methods such as GetMouseLocation().

For seamless cross-platform compatibility on mixed-input devices, see PreferredInput which more accurately reflects which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 6

Tags: [ReadOnly, NotReplicated]

MouseIcon

TypeDefault
ContentId

This property determines the content ID of the image for the user's mouse icon. If blank, a default arrow pointer is used. While the cursor hovers over certain UI objects such as an ImageButton, TextButton, TextBox, or ProximityPrompt, this image will be overridden and temporarily ignored.

To hide the cursor entirely, do not use a transparent image; instead, set MouseIconEnabled to false.

History 2

MouseIconEnabled

TypeDefault
bool

This property determines whether the mouse icon is visible.

History 4

OnScreenKeyboardPosition

TypeDefault
Vector2

This property describes the position of the on-screen keyboard in pixels. The keyboard's position is Vector2.new(0, 0) when it is not visible.

See also OnScreenKeyboardVisible and OnScreenKeyboardSize.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 4

Tags: [ReadOnly, NotReplicated]

OnScreenKeyboardSize

TypeDefault
Vector2

This property describes the size of the on-screen keyboard in pixels. The keyboard's size is Vector2.new(0, 0) when it is not visible.

See also OnScreenKeyboardVisible and OnScreenKeyboardPosition.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 4

Tags: [ReadOnly, NotReplicated]

OnScreenKeyboardVisible

TypeDefault
bool

This property describes whether an on-screen keyboard is currently visible on the user's screen.

See also OnScreenKeyboardSize and OnScreenKeyboardPosition.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 4

Tags: [ReadOnly, NotReplicated]

PointerAction

Parameters (4)
wheelfloat
panVector2
pinchfloat
gameProcessedEventbool

This event fires when the user performs a specific pointer action (wheel, pan, pitch).

History 2

PreferredInput

TypeDefault
PreferredInput

This read-only property lets you query the primary input type a player is likely using, based on anticipated user behavior, to ensure 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 behavior of PreferredInput is summarized in the following table. Its value changes based on the value of legacy UserInputService properties such as KeyboardEnabled, GamepadEnabled, and TouchEnabled, as well as the player's most recent interaction with a connected gamepad or keyboard/mouse.

KeyboardEnabled;
GamepadEnabled;
TouchEnabled
Most Recent InteractionPreferredInputExample
falsefalsetrue(don't care)Touch
truefalse;  (don't care)(don't care)KeyboardAndMouse
falsetrue;  (don't care)(don't care)Gamepad
truetrue;  (don't care)Keyboard or MouseKeyboardAndMouse
truetrue;  (don't care)GamepadGamepad
⒜ Phone with no other connected input devices; no possibility of an input type change
⒝ Mobile device with bluetooth keyboard and mouse connected, but no connected gamepad
⒞ Tablet with a gamepad connected, but no connected mouse/keyboard
⒟ Xbox or PlayStation with a bluetooth keyboard/mouse connected, and keyboard or mouse most recently interacted with
⒠ Windows or Mac with a gamepad connected, and gamepad most recently interacted with
This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 1

Tags: [ReadOnly, NotReplicated]

RecenterUserHeadCFrame

Parameters (0)
No parameters.
Returns (1)
null

This method recenters the CFrame of the VR headset to the current orientation of the headset worn by the user. This means that the headset's current orientation is set to CFrame.new().

This method behaves identically to the VRService method RecenterUserHeadCFrame().

History 3

SendAppUISizes

Parameters (4)
statusBarSizeVector2
navBarSizeVector2
bottomBarSizeVector2
rightBarSizeVector2
Returns (1)
null

History 4

SetNavigationGamepad

Parameters (2)
gamepadEnumUserInputType
enabledbool
Returns (1)
null

This method sets whether the specified gamepad can move the GuiObject navigator.

Use IsNavigationGamepad() to check if a specified gamepad is a set to be a navigation gamepad, or GetNavigationGamepads() to retrieve a list of all navigation gamepads.

History 3

StatusBarTapped

Parameters (1)
positionVector2

History 2

TextBoxFocusReleased

Parameters (1)
textboxReleasedTextBox

This event fires when the client loses focus on a TextBox, typically when a user stops text entry by pressing Enter or clicking/touching elsewhere on the screen. Can be used alongside TextBoxFocused to track when a TextBox gains focus.

See also GetFocusedTextBox(), TextBox.Focused, and TextBox.FocusLost.

History 3

TextBoxFocused

Parameters (1)
textboxFocusedTextBox

This event fires when the client gains focus on a TextBox, typically when a user clicks/taps it to begin inputting text. Also fires if the TextBox is focused using TextBox:CaptureFocus(). Can be used alongside TextBoxFocusReleased to track when a TextBox loses focus.

See also GetFocusedTextBox(), TextBox.Focused, and TextBox.FocusLost.

History 3

TouchDrag

Parameters (3)
dragDirectionSwipeDirection
numberOfTouchesint
gameProcessedEventbool

This event fires when the user drags on the screen of a TouchEnabled device.

Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.

History 2

TouchEnabled

TypeDefault
bool

This property describes whether the user's device has a touch screen available. If true, you can use touch‑related events such as TouchStarted and TouchMoved.

For seamless cross-platform compatibility on mixed-input devices, see PreferredInput which more accurately reflects which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 6

Tags: [ReadOnly, NotReplicated]

TouchEnded

Parameters (2)
touchInputObject
gameProcessedEventbool

This event fires when a user releases their finger from the screen of a TouchEnabled device. Can be paired with TouchStarted to determine when a user starts and stops touching the screen.

Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.

History 7

TouchLongPress

Parameters (3)
touchPositionsArray
stateUserInputState
gameProcessedEventbool

This event fires when a user holds at least one finger for a short amount of time on the screen of a TouchEnabled device.

Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.

History 8

TouchMoved

Parameters (2)
touchInputObject
gameProcessedEventbool

This event fires when a user moves their finger on the screen of a TouchEnabled device, useful for tracking whether a user is moving their finger on the screen and where they're moving it. Can be paired with TouchStarted and TouchEnded to determine when a user starts touching the screen, how their finger moves while touching it, and when the they stop touching the screen.

Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.

History 7

TouchPan

Parameters (5)
touchPositionsArray
totalTranslationVector2
velocityVector2
stateUserInputState
gameProcessedEventbool

This event fires when the user drags at least one finger on the screen of a TouchEnabled device.

Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.

History 5

TouchPinch

Parameters (5)
touchPositionsArray
scalefloat
velocityfloat
stateUserInputState
gameProcessedEventbool

This event fires when a user performs a pinch gesture on the screen of a TouchEnabled device.

Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.

History 7

TouchRotate

Parameters (5)
touchPositionsArray
rotationfloat
velocityfloat
stateUserInputState
gameProcessedEventbool

This event fires when a user rotates two fingers on the screen of a TouchEnabled device.

Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.

History 7

TouchStarted

Parameters (2)
touchInputObject
gameProcessedEventbool

This event fires when a user places their finger on the screen of a TouchEnabled device. Can be paired with TouchEnded to determine when a user starts and stops touching the screen.

Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.

History 7

TouchSwipe

Parameters (3)
swipeDirectionSwipeDirection
numberOfTouchesint
gameProcessedEventbool

This event fires on a TouchEnabled device when a user places their finger(s) down on the screen, pans across the screen, and lifts their finger(s) off with a certain speed of movement.

For more precise tracking of touch input movement, use TouchMoved.

Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.

History 6

TouchTap

Parameters (2)
touchPositionsArray
gameProcessedEventbool

This event fires when a user taps their finger on the screen of a TouchEnabled device, regardless of whether the user taps in the 3D world or on a GuiObject element. If you're looking for an event that only fires when the user taps in the 3D world, use TouchTapInWorld.

Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.

History 6

TouchTapInWorld

Parameters (2)
positionVector2
processedByUIbool

This event fires when a user taps their finger on the screen of a TouchEnabled device and the tap location is in the 3D world rather than on a GuiObject element.

Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.

History 2

UserCFrameChanged

Parameters (2)
typeUserCFrame
valueCFrame

The UserCFrameChanged event fires when the CFrame of a VR device changes.

This event can be used to track the movement of a connected VR device.

Using the event, you can implement features such as moving the user's in-game character limbs as the user moves their VR device. This can be done by changing the CFrame of the user's in-game limbs to match the CFrame changes of the VR device using the UserCFrame enum and CFrame value arguments passed by the event.

To retrieve the CFrame of a connected VR device, use UserInputService:GetUserCFrame().

As the event fires locally, it can only be used in a LocalScript.

See also:

This event is deprecated. It exists only for backward compatibility, and should not be used for new work.

History 4

Tags: [Deprecated]

UserHeadCFrame

TypeDefault
CFrame

The UserHeadCFrame used to describe the orientation and position of a user's head, if they are actively using a virtual reality headset.

This property is deprecated. It exists only for backward compatibility, and should not be used for new work.
This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 5

Tags: [ReadOnly, NotReplicated, Deprecated]

VREnabled

TypeDefault
bool

This property describes whether the user is using a virtual reality (VR) device. If true, you can use VR‑related properties, methods, and events in VRService.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 4

Tags: [ReadOnly, NotReplicated]

WindowFocusReleased

Parameters (0)
No parameters.

This event fires when the window of the Roblox client loses focus, typically when it is minimized by the user. Can be used alongside WindowFocused to track when the client gains focus on a user's screen.

History 4

WindowFocused

Parameters (0)
No parameters.

This event fires when the window of the Roblox client gains focus, typically when it is maximized or actively opened by the user. Can be used alongside WindowFocusReleased to track when the client loses focus on a user's screen.

History 4

Removed members 10

InCameraGesture

TypeDefault
bool

History 2

IsLuaTouchControls

Parameters (0)
No parameters.
Returns (1)
bool

History 2

IsStudioTouchEmulationEnabled

Parameters (0)
No parameters.
Returns (1)
bool

History 2

IsVREnabled

TypeDefault
bool
This property is deprecated. It exists only for backward compatibility, and should not be used for new work.
This property is read-only. Its value can be read, but it cannot be modified.

History 3

Tags: [ReadOnly, Deprecated]

OverrideMouseIconEnabled

TypeDefault
bool

History 2

ProcessedEvent

Parameters (2)
inputObjectInstance
processedbool

History 2

RotateCamera

Parameters (1)
positionDeltaVector2
Returns (1)
void

History 2

TouchControlsEnabled

TypeDefault
bool

History 2

ZoomCamera

Parameters (1)
zoomDeltafloat
Returns (1)
void

History 2

Settings