Service · inherits Instance
UserInputService
UserInputService is primarily used to detect the input types available on a
user's device, as well as detect input events.
About UserInputService
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.
Properties 15
AccelerometerEnabled
: booleanReadOnlyNotReplicatedDescribes whether the user's device has an accelerometer.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 theDeviceAccelerationChangedevent.GamepadEnabled
: booleanReadOnlyNotReplicatedDescribes whether the user's device has an available gamepad.This property describes whether the user's device has an available gamepad. If
true, you can use gamepad‑related methods such asGetConnectedGamepads().For seamless cross-platform compatibility on mixed-input devices, see
PreferredInputwhich more accurately reflects which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.GyroscopeEnabled
: booleanReadOnlyNotReplicatedDescribes whether the user's device has a gyroscope.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 theDeviceRotationChangedevent.KeyboardEnabled
: booleanReadOnlyNotReplicatedDescribes whether the user's device has a keyboard available.This property describes whether the user's device has a keyboard available. If
true, you can use key‑related methods such asIsKeyDown()orGetKeysPressed().For seamless cross-platform compatibility on mixed-input devices, see
PreferredInputwhich more accurately reflects which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.MouseBehavior
: MouseBehaviorDetermines whether the user's mouse can be moved freely or is locked.This property sets how the user's mouse behaves based on the
MouseBehaviorenum. It can be set to three values:MouseBehavior.Default— The mouse moves freely around the user's screen.MouseBehavior.LockCenter— The mouse is locked and cannot move from the center of the user's screen.MouseBehavior.LockCurrentPosition— The mouse is locked and cannot move from its current position on the user's screen at the time of locking.
The value of this property does not affect the sensitivity of events tracking mouse movement. For example,
GetMouseDeltareturns the sameVector2screen 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
GuiButtonwithModalenabled isVisibleunless the player's right mouse button is down.Note that if the mouse is locked,
InputChangedwill 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.MouseDeltaSensitivity
: floatNotReplicatedScales the delta (change) output of the user'sMouse.This property determines the sensitivity of the user's
Mouse. It can be used to adjust the sensitivity of events tracking mouse movement, such asGetMouseDelta().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
10and a minimum value of0. When sensitivity is0, events that track the mouse's movement will still fire but all parameters and properties indicating the change in mouse position will return0.MouseEnabled
: booleanReadOnlyNotReplicatedDescribes whether the user's device has a mouse available.This property describes whether the user's device has a mouse available. If
true, you can use mouse‑related methods such asGetMouseLocation().For seamless cross-platform compatibility on mixed-input devices, see
PreferredInputwhich more accurately reflects which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.MouseIcon
: ContentIdThe content ID of the image for the user's mouse icon.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, orProximityPrompt, this image will be overridden and temporarily ignored.To hide the cursor entirely, do not use a transparent image; instead, set
MouseIconEnabledtofalse.MouseIconContent
: ContentThe content ID of the image for the user's mouse icon. Only supports asset URIs.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, orProximityPrompt, this image will be overridden and temporarily ignored. Only asset URIs are supported for this property.To hide the cursor entirely, do not use a transparent image; instead, set
MouseIconEnabledtofalse.MouseIconEnabled
: booleanDetermines whether the mouse icon is visible.This property determines whether the mouse icon is visible. To detect when this property changes, you must listen to when the
MouseEnabledproperty changes.OnScreenKeyboardPosition
: Vector2ReadOnlyNotReplicatedDetermines the position of the on-screen keyboard.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
OnScreenKeyboardVisibleandOnScreenKeyboardSize.OnScreenKeyboardSize
: Vector2ReadOnlyNotReplicatedDetermines the size of the on-screen keyboard.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
OnScreenKeyboardVisibleandOnScreenKeyboardPosition.OnScreenKeyboardVisible
: booleanReadOnlyNotReplicatedDescribes whether an on-screen keyboard is currently visible on the user's screen.This property describes whether an on-screen keyboard is currently visible on the user's screen.
See also
OnScreenKeyboardSizeandOnScreenKeyboardPosition.PreferredInput
: PreferredInputReadOnlyNotReplicatedQueries the primary input type a player is using, based on anticipated user behavior.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 value of
PreferredInputchanges based on built‑in device inputs and the player's most recent interaction with a connected gamepad or keyboard/mouse. Examples include:TouchEnabled
: booleanReadOnlyNotReplicatedDescribes whether the user's device has a touch screen available.This property describes whether the user's device has a touch screen available. If
true, you can use touch‑related events such asTouchStartedandTouchMoved.For seamless cross-platform compatibility on mixed-input devices, see
PreferredInputwhich more accurately reflects which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.
Methods 24
CreateVirtualInput
() → ObjectCreates aVirtualInputobject for simulating mouse, keyboard, and pointer input.This method creates a
VirtualInputobject for simulating mouse, keyboard, and pointer input as if it were performed by a real user. It is intended for testing and automation workflows that need to simulate user interaction inside a running experience. Simulated input is restricted to the experience's own UI elements and cannot interact with arbitrary or system-level GUI.Always check that the returned value is not
nilbefore calling any methods on it.GamepadSupports
(gamepadNum: UserInputType, gamepadKeyCode: KeyCode) → booleanReturns whether the givenUserInputTypegamepad supports a button corresponding with the givenKeyCode.This method returns whether the given
UserInputTypegamepad supports a button corresponding with the givenKeyCode.GetConnectedGamepads
() → ArrayReturns an array ofUserInputTypegamepads currently connected.This method returns an array of
UserInputTypegamepads currently connected. If no gamepads are connected, the array will be empty.Alternatively to detecting all gamepads, the
PreferredInputproperty can be used to more accurately reflect which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.GetDeviceAcceleration
() → InputObjectReturns anInputObjectthat describes the device's current acceleration.This method returns an
InputObjectthat describes the device's current acceleration. For this to function, the user's device must have an enabled accelerometer as queried through theAccelerometerEnabledproperty.To track when the device's acceleration changes, use the
DeviceAccelerationChangedevent.GetDeviceGravity
() → InputObjectReturns anInputObjectdescribing the device's current gravity vector.This method returns an
InputObjectdescribing 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:Vector3.new(0, 0, -9.81)if the device is perfectly upright (portrait)Vector3.new(9.81, 0, 0)if the left side of the device is pointing downVector3.new(0, -9.81, 0)if the back of the device is pointing down
Gravity is only tracked for devices with an enabled gyroscope as queried through
GyroscopeEnabled.To track when the device's gravity changes, use the
DeviceGravityChangedevent.GetDeviceRotation
() → TupleReturns anInputObjectand aCFramedescribing the device's current rotation vector.This method returns an
InputObjectand aCFramedescribing the device's current rotation vector.Device rotation is only tracked for devices with an enabled gyroscope as queried through
GyroscopeEnabled.GetFocusedTextBox
() → TextBoxReturns theTextBoxthe client is currently focused on.This method returns the
TextBoxthe client is currently focused on. ATextBoxcan be manually selected by the user, or selection can be forced using theTextBox.CaptureFocusmethod. If noTextBoxis selected, this method will returnnil.GetGamepadConnected
(gamepadNum: UserInputType) → booleanReturns whether a gamepad with the givenUserInputTypeis connected.This method returns whether a gamepad with the given
UserInputTypeis connected.Alternatively to detecting a specific gamepad by
UserInputType, thePreferredInputproperty can be used to more accurately reflect which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.GetGamepadState
(gamepadNum: UserInputType) → List<InputObject>Returns an array ofInputObjectsfor all available inputs on the given gamepad, representing each input's last input state.This method returns an array of
InputObjectsfor all available inputs on the givenUserInputTypegamepad, representing each input's last input state.GetImageForKeyCode
(keyCode: KeyCode) → ContentIdReturns an image for the requestedKeyCode.This method takes the requested
KeyCodeand 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, seeGetStringForKeyCode().For most use cases, consider using
InputActionLabelinstead. It is aGuiObjectthat automatically displays the correct key icon for anInputActionand updates when the player switches input devices or rebinds the action, without any scripting.GetImageForKeyCode()remains useful for advanced or fully custom interfaces where you need direct access to the underlying image asset.GetKeysPressed
() → List<InputObject>Returns an array ofInputObjectsassociated with thekeyscurrently being pressed down.This method returns an array of
InputObjectsassociated with the keys currently being pressed down. The array can be iterated through to determine which keys are currently being pressed, using theInputObject.KeyCodenames or values.To check if a specific key is being pressed, use
IsKeyDown().GetLastInputType
() → UserInputTypeReturns theUserInputTypeassociated with the user's most recent input.This method returns the
UserInputTypeassociated with the user's most recent input. For example, if the user's previous input had been pressing the A key, the returnedUserInputTypevalue would beKeyboard.For seamless cross-platform compatibility on mixed-input devices, see
PreferredInputwhich 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 recentUserInputType.GetMouseButtonsPressed
() → List<InputObject>Returns an array ofInputObjectsassociated with the mouse buttons currently being held down.This method returns an array of
InputObjectsassociated with the mouse buttons currently being held down. The array can be iterated through to determine which buttons are currently being held, using theInputObject.KeyCodenames or values.Mouse buttons that are tracked by this method include
MouseButton1(left),MouseButton2(right), andMouseButton3(middle).If the user is not pressing any mouse button down when the method is called, it will return an empty array.
GetMouseDelta
() → Vector2Returns the change, in pixels, of the position of the player'sMousein the last rendered frame. Only works if the mouse is locked.This method returns the change, in pixels, of the position of the player's
Mousein the last rendered frame, only if the mouse has been locked using theMouseBehaviorproperty; otherwise the returnedVector2values will be0.The sensitivity of the mouse, determined in the client's settings and
MouseDeltaSensitivity, will influence the result.GetMouseLocation
() → Vector2Returns the current screen location of the player'sMouserelative to the top-left corner of the screen.This method returns a
Vector2representing the current screen location of the player'sMousein pixels relative to the top‑left corner. This does not account for theScreenInsets; to get the top‑left and bottom‑right insets, callGuiService.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.
GetStringForKeyCode
(keyCode: KeyCode, format: KeyCodeStringFormat = Default) → stringReturns a string representing a key the user should press in order to input a givenKeyCode, optionally in an abbreviated format.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.For most use cases, consider using
InputActionLabelinstead. It is aGuiObjectthat automatically displays the correct key text or icon for anInputActionand updates when the player switches input devices or rebinds the action, without any scripting.GetStringForKeyCode()remains useful for advanced or fully custom interfaces where you need the raw display string.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.Abbreviated Format
When
formatis set toKeyCodeStringFormat.Abbreviated, the method returns shortened key names suitable for compact UI elements, for example"LCtrl"instead of"LeftControl","Bksp"instead of"Backspace", or"Esc"instead of"Escape". If no abbreviation exists for the given key code, the default string is returned.Gamepad Usage
GetStringForKeyCode()returns the string mapping for theKeyCodefor 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 = imageGamepad Mappings
The directional pad key codes do not have any differences based on device.
KeyCode.ButtonSelecthas slightly different behavior in some cases. Use both PlayStation mappings to ensure users see the correct buttons.Legacy System Images
When using a
KeyCodethat may be better represented as an image, such as for anImageLabelin a user interface, you can use the following legacy icons. However, it's recommended that you useGetImageForKeyCode()as a more modern, cross‑platform method to retrieve Xbox and PlayStation controller icons.GetSupportedGamepadKeyCodes
(gamepadNum: UserInputType) → ArrayReturns an array ofKeyCodesthat the gamepad associated with the givenUserInputTypesupports.This method returns an array of
KeyCodesthat the gamepad associated with the givenUserInputTypesupports. If called on a non‑connected gamepad, returns an empty array.To determine if a specific
KeyCodeis supported, useGamepadSupports().IsGamepadButtonDown
(gamepadNum: UserInputType, gamepadKeyCode: KeyCode) → booleanDetermines whether a particular button is pressed on a gamepad.This method returns
trueif a particular button is pressed on a gamepad, otherwise returnsfalse.See also
InputBindingas a way to hook gamepad and other input interactions toInputActions.IsKeyDown
(keyCode: KeyCode) → booleanReturns whether the givenkeyis currently held down.This method returns
trueif a particular key is pressed on a keyboard, otherwise returnsfalse.See also
InputBindingas a way to hook key and other input interactions toInputActions.IsMouseButtonPressed
(mouseButton: UserInputType) → booleanReturns whether the given mouse button is currently held down.This method returns
trueif a particular mouse button is pressed, otherwise returnsfalse.See also
InputBindingas a way to hook mouse button and other input interactions toInputActions.RecenterUserHeadCFrame
() → ()Recenters theCFrameof the VR headset to the current orientation of the headset worn by the user.This method recenters the
CFrameof the VR headset to the current orientation of the headset worn by the user. This means that the headset's current orientation is set toCFrame.new.This method behaves identically to the
VRServicemethodRecenterUserHeadCFrame().
Events 26
DeviceAccelerationChanged
UserInputService.DeviceAccelerationChanged:Connect(function(acceleration))Fires when a user moves a device that has an accelerometer.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.DeviceGravityChanged
UserInputService.DeviceGravityChanged:Connect(function(gravity))Fires when the force of gravity changes on a device that has an enabled accelerometer.This event fires when the device's gravity
Vector3changes on a device that has an accelerometer. To determine whether a user's device has an accelerometer enabled, useAccelerometerEnabled.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
-1to1.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.DeviceRotationChanged
UserInputService.DeviceRotationChanged:Connect(function(rotation, cframe))Fires when a user rotates a device that has a gyroscope.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.
GamepadConnected
UserInputService.GamepadConnected:Connect(function(gamepadNum))Fires when a gamepad is connected to the client.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
PreferredInputproperty which more accurately reflects which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.See also
GamepadDisconnected.GamepadDisconnected
UserInputService.GamepadDisconnected:Connect(function(gamepadNum))Fires when a gamepad is disconnected from the client.This event fires when a gamepad is disconnected from the client.
Alternatively, you can detect value changes to the
PreferredInputproperty which more accurately reflects which input (mouse/keyboard, touch, gamepad, etc.) the player is likely using as the primary input.See also
GamepadConnected.InputBegan
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent))Fires when a user begins interacting with an input device such as a mouse or gamepad.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
InputChangedandInputEndedto track when user input begins, changes, and ends.See also
InputBindingas a way to hook input device interactions toInputActions.Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.
InputChanged
UserInputService.InputChanged:Connect(function(input, gameProcessedEvent))Fires when a user changes how they're interacting with an input device such as a mouse or gamepad.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
InputBeganandInputEndedto track when user input begins, changes, and ends.See also
InputBindingas a way to hook input device interactions toInputActions.Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.
InputEnded
UserInputService.InputEnded:Connect(function(input, gameProcessedEvent))Fires when a user stops interacting with an input device such as a mouse or gamepad.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
InputBeganandInputChangedto track when user input begins, changes, and ends.See also
InputBindingas a way to hook input device interactions toInputActions.Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.
JumpRequest
UserInputService.JumpRequest:Connect(function())Fires whenever the client makes a request for their character to jump.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.Jumpproperty totruewhich makes the player's character jump.Since this event fires multiple times for a single jump request, using a debounce is recommended. This event does not fire if
Player.Characteris set to nil.LastInputTypeChanged
UserInputService.LastInputTypeChanged:Connect(function(lastInputType))Fires whenever the client'sUserInputTypeis changed.This event fires whenever the client's
UserInputTypeis changed.To get the value of the last input type, regardless of whether it has changed, use the
GetLastInputType()method.PointerAction
UserInputService.PointerAction:Connect(function(wheel, pan, pinch, gameProcessedEvent))Fires when the user performs a specific pointer action.This event fires when the user performs a specific pointer action (
wheel,pan,pitch).TextBoxFocused
UserInputService.TextBoxFocused:Connect(function(textboxFocused))Fires when the client focuses on aTextBox.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 theTextBoxis focused usingTextBox.CaptureFocus. Can be used alongsideTextBoxFocusReleasedto track when aTextBoxloses focus.See also
GetFocusedTextBox(),TextBox.Focused, andTextBox.FocusLost.TextBoxFocusReleased
UserInputService.TextBoxFocusReleased:Connect(function(textboxReleased))Fires when the client loses focus on aTextBox.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 alongsideTextBoxFocusedto track when aTextBoxgains focus.See also
GetFocusedTextBox(),TextBox.Focused, andTextBox.FocusLost.TouchDrag
UserInputService.TouchDrag:Connect(function(dragDirection, numberOfTouches, gameProcessedEvent))Fires when the user drags on the screen of aTouchEnableddevice.This event fires when the user drags on the screen of a
TouchEnableddevice. Use this event to detect the start of a deliberate directional gesture (for example, sliding an element left or right to reveal contextual actions) before the user commits to a direction; for detecting a completed swipe or fling gesture, useTouchSwipeinstead.Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.
TouchEnded
UserInputService.TouchEnded:Connect(function(touch, gameProcessedEvent))Fires when a user releases their finger from the screen of aTouchEnableddevice.This event fires when a user releases their finger from the screen of a
TouchEnableddevice. Can be paired withTouchStartedto 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.
TouchLongPress
UserInputService.TouchLongPress:Connect(function(touchPositions, state, gameProcessedEvent))Fires when a user holds at least one finger for a short amount of time on the screen of aTouchEnableddevice.This event fires when a user holds at least one finger for a short amount of time on the screen of a
TouchEnableddevice.Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.
TouchMoved
UserInputService.TouchMoved:Connect(function(touch, gameProcessedEvent))Fires when a user moves their finger on the screen of aTouchEnableddevice.This event fires when a user moves their finger on the screen of a
TouchEnableddevice, useful for tracking whether a user is moving their finger on the screen and where they're moving it. Can be paired withTouchStartedandTouchEndedto 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.
TouchPan
UserInputService.TouchPan:Connect(function(touchPositions, totalTranslation, velocity, state, gameProcessedEvent))Fires when the user drags at least one finger on the screen of aTouchEnableddevice.This event fires when the user drags at least one finger on the screen of a
TouchEnableddevice.Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.
TouchPinch
UserInputService.TouchPinch:Connect(function(touchPositions, scale, velocity, state, gameProcessedEvent))Fires when a user performs a pinch gesture on the screen of aTouchEnableddevice.This event fires when a user performs a pinch gesture on the screen of a
TouchEnableddevice.Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.
TouchRotate
UserInputService.TouchRotate:Connect(function(touchPositions, rotation, velocity, state, gameProcessedEvent))Fires when a user rotates two fingers on the screen of aTouchEnableddevice.This event fires when a user rotates two fingers on the screen of a
TouchEnableddevice.Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.
TouchStarted
UserInputService.TouchStarted:Connect(function(touch, gameProcessedEvent))Fires when a user places their finger on the screen of aTouchEnableddevice.This event fires when a user places their finger on the screen of a
TouchEnableddevice. Can be paired withTouchEndedto 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.
TouchSwipe
UserInputService.TouchSwipe:Connect(function(swipeDirection, numberOfTouches, gameProcessedEvent))Fires on aTouchEnableddevice 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.This event fires on a
TouchEnableddevice 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.
TouchTap
UserInputService.TouchTap:Connect(function(touchPositions, gameProcessedEvent))Fires when a user taps their finger on the screen of aTouchEnableddevice.This event fires when a user taps their finger on the screen of a
TouchEnableddevice, regardless of whether the user taps in the 3D world or on aGuiObjectelement. If you're looking for an event that only fires when the user taps in the 3D world, useTouchTapInWorld.Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.
TouchTapInWorld
UserInputService.TouchTapInWorld:Connect(function(position, processedByUI))Fires when a user taps their finger on the screen of aTouchEnableddevice and the tap location is in the 3D world.This event fires when a user taps their finger on the screen of a
TouchEnableddevice and the tap location is in the 3D world rather than on aGuiObjectelement.Note that this event only fires when the Roblox client window is in focus. It will not fire when the window is minimized.
WindowFocused
UserInputService.WindowFocused:Connect(function())Fires when the window of the Roblox client gains focus on the user's screen.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
WindowFocusReleasedto track when the client loses focus on a user's screen.WindowFocusReleased
UserInputService.WindowFocusReleased:Connect(function())Fires when the window of the Roblox client loses focus on the user's screen.This event fires when the window of the Roblox client loses focus, typically when it is minimized by the user. Can be used alongside
WindowFocusedto track when the client gains focus on a user's screen.
UserInputService also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.