PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

TouchLongPress

Fired when a user holds at least one finger for a short amount of time on the same screen position of a TouchEnabled device.

This event can be used to determine when a user holds their finger down on an an-game GuiObject|GUI or element.

The example below prints the Enum/UserInputState|state of the long press when the user user holds at least one finger for a short amount of time on the same screen position. Possible states include: Begin, Change, End, Cancel, and None.

local userInputService = game:GetService("UserInputService")

function TouchLongPress(TouchPositions, state, gameProcessedEvent)
	print("Long press event fired. State of press: "..tostring(state))
end

userInputService.TouchLongPress:Connect(TouchLongPress)

To check if a user’s device is TouchEnabled, and that touch events will fire, seeUserInputService/TouchEnabled.

It can be paired with UserInputService/TouchStarted and UserInputService/TouchEnded to determine when a user starts and stops touching the screen.

This event only fires when the Roblox client window is in focus. For example, inputs will not be captured when the window is minimized.

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

See also

  • UserInputService/TouchTap
  • UserInputService/TouchTapInWorld
  • UserInputService/TouchMoved
  • UserInputService/TouchPan
  • UserInputService/TouchPinch
  • UserInputService/TouchRotate
  • UserInputService/TouchSwipe
  • UserInputService/TouchStarted
  • UserInputService/TouchEnded

Parameters

Name Type Default Description

An array of DataType/Vector2s, indicating the position of the fingers involved in the gesture

The Enum/UserInputState of the gesture

Indicates whether the game engine internally observed this input and acted on it. Generally this refers to UI processing, so if a button was touched or clicked from this input, gameProcessedEvent would be true. This is also true for input events connected via ContextActionService