UserInputService

extends Instance

Class fields

FieldXML typeValue
NamestringUserInputService

Properties

12
AccelerometerEnabled
bool
FieldXML typeValue
NamestringAccelerometerEnabled
summarystringReturns true if the local device has an accelerometer, false otherwise.
GamepadEnabled
bool
FieldXML typeValue
NamestringGamepadEnabled
GyroscopeEnabled
bool
FieldXML typeValue
NamestringGyroscopeEnabled
summarystringReturns true if the local device has an gyroscope, false otherwise.
KeyboardEnabled
bool
FieldXML typeValue
NamestringKeyboardEnabled
summarystringReturns true if the local device accepts keyboard input, false otherwise.
ModalEnabled
bool
FieldXML typeValue
NamestringModalEnabled
MouseBehavior
MouseBehavior
FieldXML typeValue
NamestringMouseBehavior
MouseEnabled
bool
FieldXML typeValue
NamestringMouseEnabled
summarystringReturns true if the local device accepts mouse input, false otherwise.
MouseIconEnabled
bool
FieldXML typeValue
NamestringMouseIconEnabled
OverrideMouseIconBehavior
OverrideMouseIconBehavior
FieldXML typeValue
NamestringOverrideMouseIconBehavior
TouchEnabled
bool
FieldXML typeValue
NamestringTouchEnabled
summarystringReturns true if the local device accepts touch input, false otherwise.
UserHeadCFrame
CoordinateFrame
FieldXML typeValue
NamestringUserHeadCFrame
VREnabled
bool
FieldXML typeValue
NamestringVREnabled

Functions

18
GamepadSupports
(gamepadNum: UserInputType, gamepadKeyCode: KeyCode) → bool
FieldXML typeValue
NamestringGamepadSupports
GetConnectedGamepads
() → Array
FieldXML typeValue
NamestringGetConnectedGamepads
GetDeviceAcceleration
() → Instance
FieldXML typeValue
NamestringGetDeviceAcceleration
summarystringReturns an InputObject that describes the device's current acceleration. This is fired with an InputObject, which has type Enum.InputType.Accelerometer, and position that shows the g force in each local device axis. The delta property describes the amount of rotation that last happened. This event only fires locally.
GetDeviceGravity
() → Instance
FieldXML typeValue
NamestringGetDeviceGravity
summarystringReturns an InputObject that describes the device's current gravity vector. This is fired with an InputObject, which has type Enum.InputType.Accelerometer, and position that shows the g force in each local device axis. The delta property describes the amount of rotation that last happened. This event only fires locally.
GetDeviceRotation
() → Tuple
FieldXML typeValue
NamestringGetDeviceRotation
summarystringReturns an InputObject and a Vector4 that describes the device's current rotation vector. This is fired with an InputObject, which has type Enum.InputType.Gyroscope, and position that shows total rotation in each local device axis. The delta property describes the amount of rotation that last happened. The Vector4 is the device's current quaternion rotation in reference to it's default reference frame. This event only fires locally.
GetFocusedTextBox
() → Instance
FieldXML typeValue
NamestringGetFocusedTextBox
GetGamepadConnected
(gamepadNum: UserInputType) → bool
FieldXML typeValue
NamestringGetGamepadConnected
GetGamepadState
(gamepadNum: UserInputType) → Array
FieldXML typeValue
NamestringGetGamepadState
GetKeysPressed
() → Array
FieldXML typeValue
NamestringGetKeysPressed
GetLastInputType
() → UserInputType
FieldXML typeValue
NamestringGetLastInputType
GetNavigationGamepads
() → Array
FieldXML typeValue
NamestringGetNavigationGamepads
GetPlatform
() → Platform
FieldXML typeValue
NamestringGetPlatform
GetSupportedGamepadKeyCodes
(gamepadNum: UserInputType) → Array
FieldXML typeValue
NamestringGetSupportedGamepadKeyCodes
GetUserCFrame
(type: UserCFrame) → CoordinateFrame
FieldXML typeValue
NamestringGetUserCFrame
IsKeyDown
(keyCode: KeyCode) → bool
FieldXML typeValue
NamestringIsKeyDown
IsNavigationGamepad
(gamepadEnum: UserInputType) → bool
FieldXML typeValue
NamestringIsNavigationGamepad
RecenterUserHeadCFrame
() → void
FieldXML typeValue
NamestringRecenterUserHeadCFrame
SetNavigationGamepad
(gamepadEnum: UserInputType, enabled: bool) → void
FieldXML typeValue
NamestringSetNavigationGamepad

Events

24
DeviceAccelerationChanged
(acceleration: Instance) → void
FieldXML typeValue
NamestringDeviceAccelerationChanged
summarystringFired when a user moves a device that has an accelerometer. This is fired with an InputObject, which has type Enum.InputType.Accelerometer, and position that shows the g force in each local device axis. This event only fires locally.
DeviceGravityChanged
(gravity: Instance) → void
FieldXML typeValue
NamestringDeviceGravityChanged
summarystringFired when the force of gravity changes on a device that has an accelerometer. This is fired with an InputObject, which has type Enum.InputType.Accelerometer, and position that shows the g force in each local device axis. This event only fires locally.
DeviceRotationChanged
(rotation: Instance, cframe: CoordinateFrame) → void
FieldXML typeValue
NamestringDeviceRotationChanged
summarystringFired when a user rotates a device that has an gyroscope. This is fired with an InputObject, which has type Enum.InputType.Gyroscope, and position that shows total rotation in each local device axis. The delta property describes the amount of rotation that last happened. A second argument of Vector4 is the device's current quaternion rotation in reference to it's default reference frame. This event only fires locally.
GamepadConnected
(gamepadNum: UserInputType) → void
FieldXML typeValue
NamestringGamepadConnected
GamepadDisconnected
(gamepadNum: UserInputType) → void
FieldXML typeValue
NamestringGamepadDisconnected
InputBegan
(input: Instance, gameProcessedEvent: bool) → void
FieldXML typeValue
NamestringInputBegan
summarystringFired when a user begins interacting via a Human-Computer Interface device (Mouse button down, touch begin, keyboard button down, etc.). 'inputObject' is an InputObject, which contains useful data for querying user input. This event only fires locally. This event will always fire regardless of game state.
InputChanged
(input: Instance, gameProcessedEvent: bool) → void
FieldXML typeValue
NamestringInputChanged
summarystringFired when a user changes interacting via a Human-Computer Interface device (Mouse move, touch move, mouse wheel, etc.). 'inputObject' is an InputObject, which contains useful data for querying user input. This event only fires locally. This event will always fire regardless of game state.
InputEnded
(input: Instance, gameProcessedEvent: bool) → void
FieldXML typeValue
NamestringInputEnded
summarystringFired when a user stops interacting via a Human-Computer Interface device (Mouse button up, touch end, keyboard button up, etc.). 'inputObject' is an InputObject, which contains useful data for querying user input. This event only fires locally. This event will always fire regardless of game state.
JumpRequest
() → void
FieldXML typeValue
NamestringJumpRequest
LastInputTypeChanged
(lastInputType: UserInputType) → void
FieldXML typeValue
NamestringLastInputTypeChanged
TextBoxFocusReleased
(textboxReleased: Instance) → void
FieldXML typeValue
NamestringTextBoxFocusReleased
summarystringFired when a user stops text entry into a textbox (usually by pressing return or clicking/tapping somewhere else on the screen). Argument is the textbox that was taken out of focus. This event only fires locally.
TextBoxFocused
(textboxFocused: Instance) → void
FieldXML typeValue
NamestringTextBoxFocused
summarystringFired when a user clicks/taps on a textbox to begin text entry. Argument is the textbox that was put in focus. This also fires if a textbox forces focus on the user. This event only fires locally.
TouchEnded
(touch: Instance, gameProcessedEvent: bool) → void
FieldXML typeValue
NamestringTouchEnded
summarystringFired when a user moves their finger on a TouchEnabled device. 'touch' is an InputObject, which contains useful data for querying user input. This event only fires locally. This event will always fire regardless of game state.
TouchLongPress
(touchPositions: Array, state: UserInputState, gameProcessedEvent: bool) → void
FieldXML typeValue
NamestringTouchLongPress
summarystringFired when a user holds at least one finger for a short amount of time on the same screen position on a TouchEnabled device. 'touchPositions' is a Lua array of Vector2, each indicating the position of all the fingers involved in the gesture. 'state' indicates the Enum.UserInputState of the gesture. This event only fires locally. This event will always fire regardless of game state.
TouchMoved
(touch: Instance, gameProcessedEvent: bool) → void
FieldXML typeValue
NamestringTouchMoved
summarystringFired when a user moves their finger on a TouchEnabled device. 'touch' is an InputObject, which contains useful data for querying user input. This event only fires locally. This event will always fire regardless of game state.
TouchPan
(touchPositions: Array, totalTranslation: Vector2, velocity: Vector2, state: UserInputState, gameProcessedEvent: bool) → void
FieldXML typeValue
NamestringTouchPan
summarystringFired when a user drags at least one finger on a TouchEnabled device. 'touchPositions' is a Lua array of Vector2, each indicating the position of all the fingers involved in the gesture. 'totalTranslation' is a Vector2, indicating how far the pan gesture has gone from its starting point. 'velocity' is a Vector2 that indicates how quickly the gesture is being performed in each dimension. 'state' indicates the Enum.UserInputState of the gesture. This event only fires locally. This event will always fire regardless of game state.
TouchPinch
(touchPositions: Array, scale: float, velocity: float, state: UserInputState, gameProcessedEvent: bool) → void
FieldXML typeValue
NamestringTouchPinch
summarystringFired when a user pinches their fingers on a TouchEnabled device. 'touchPositions' is a Lua array of Vector2, each indicating the position of all the fingers involved in the pinch gesture. 'scale' is a float that indicates the difference from the beginning of the pinch gesture. 'velocity' is a float indicating how quickly the pinch gesture is happening. 'state' indicates the Enum.UserInputState of the gesture. This event only fires locally. This event will always fire regardless of game state.
TouchRotate
(touchPositions: Array, rotation: float, velocity: float, state: UserInputState, gameProcessedEvent: bool) → void
FieldXML typeValue
NamestringTouchRotate
summarystringFired when a user rotates two fingers on a TouchEnabled device. 'touchPositions' is a Lua array of Vector2, each indicating the position of all the fingers involved in the gesture. 'rotation' is a float indicating how much the rotation has gone from the start of the gesture. 'velocity' is a float that indicates how quickly the gesture is being performed. 'state' indicates the Enum.UserInputState of the gesture. This event only fires locally. This event will always fire regardless of game state.
TouchStarted
(touch: Instance, gameProcessedEvent: bool) → void
FieldXML typeValue
NamestringTouchStarted
summarystringFired when a user places their finger on a TouchEnabled device. 'touch' is an InputObject, which contains useful data for querying user input. This event only fires locally. This event will always fire regardless of game state.
TouchSwipe
(swipeDirection: SwipeDirection, numberOfTouches: int, gameProcessedEvent: bool) → void
FieldXML typeValue
NamestringTouchSwipe
summarystringFired when a user swipes their fingers on a TouchEnabled device. 'swipeDirection' is an Enum.SwipeDirection, indicating the direction the user swiped. 'numberOfTouches' is an int that indicates how many touches were involved with the gesture. This event only fires locally. This event will always fire regardless of game state.
TouchTap
(touchPositions: Array, gameProcessedEvent: bool) → void
FieldXML typeValue
NamestringTouchTap
summarystringFired when a user taps their finger on a TouchEnabled device. 'touchPositions' is a Lua array of Vector2, each indicating the position of all the fingers involved in the tap gesture. This event only fires locally. This event will always fire regardless of game state.
UserCFrameChanged
(type: UserCFrame, value: CoordinateFrame) → void
FieldXML typeValue
NamestringUserCFrameChanged
WindowFocusReleased
() → void
FieldXML typeValue
NamestringWindowFocusReleased
WindowFocused
() → void
FieldXML typeValue
NamestringWindowFocused