Skip to content
Roblox API Reference

UserInputService

UserInputService is primarily used to detect the input types available on a user's device, as well as detect input events.
  • Not creatable
  • Not replicated
  • Service
Memory category
Instances
Own members
84
Inherited members
75
Subclasses
0
Siblings
608

Properties49

Inherited fromObject2

Property categoryData

Inherited fromInstance21

Property categoryBehavior

Property categoryData

Property categoryPermissions

Defined byUserInputService26

Property categoryBehavior

  • UserInputService.LegacyInputEventsEnabled: boolean
    • Deprecated
    • Hidden
    • Roblox script security
    • Read capabilities: Input
  • UserInputService.ModalEnabled: boolean
    Deprecated: This item has been superseded by GuiService.TouchControlsEnabled which should be used in all new work.
    Toggles whether Roblox's mobile controls are hidden on mobile devices.
    • Deprecated
    • Read capabilities: Input

    Use TouchControlsEnabled instead.

Property categoryData

  • UserInputService.AccelerometerEnabled: boolean
    Describes whether the user's device has an accelerometer.
    • Read only
    • Read capabilities: Input
    • Save only
  • UserInputService.BottomBarSize: Vector2
    • Hidden
    • Read only
    • Roblox script security
    • Read capabilities: Input
  • UserInputService.GamepadEnabled: boolean
    Describes whether the user's device has an available gamepad.
    • Read only
    • Read capabilities: Input
    • Save only
  • UserInputService.GyroscopeEnabled: boolean
    Describes whether the user's device has a gyroscope.
    • Read only
    • Read capabilities: Input
    • Save only
  • UserInputService.KeyboardEnabled: boolean
    Describes whether the user's device has a keyboard available.
    • Read only
    • Read capabilities: Input
    • Save only
  • UserInputService.MouseBehavior: Enum.MouseBehavior
    Determines whether the user's mouse can be moved freely or is locked.
    • Read capabilities: Input
  • UserInputService.MouseDeltaSensitivity: number
    Scales the delta (change) output of the user's Mouse.
    • Not replicated
    • Read capabilities: Input
    • Load only
  • UserInputService.MouseEnabled: boolean
    Describes whether the user's device has a mouse available.
    • Read only
    • Read capabilities: Input
    • Save only
  • UserInputService.MouseIcon: string
    The content ID of the image for the user's mouse icon.
    • Read capabilities: Input
  • UserInputService.MouseIconContent: Content
    The content ID of the image for the user's mouse icon. Only supports asset URIs.
    • Read capabilities: Input
  • UserInputService.MouseIconEnabled: boolean
    Determines whether the mouse icon is visible.
    • Read capabilities: Input
  • UserInputService.NavBarSize: Vector2
    • Hidden
    • Read only
    • Roblox script security
    • Read capabilities: Input
  • UserInputService.OnScreenKeyboardAnimationDuration: number
    • Hidden
    • Read only
    • Roblox script security
    • Read capabilities: Input
  • UserInputService.OnScreenKeyboardPosition: Vector2
    Determines the position of the on-screen keyboard.
    • Read only
    • Read capabilities: Input
  • UserInputService.OnScreenKeyboardSize: Vector2
    Determines the size of the on-screen keyboard.
    • Read only
    • Read capabilities: Input
  • UserInputService.OnScreenKeyboardVisible: boolean
    Describes whether an on-screen keyboard is currently visible on the user's screen.
    • Read only
    • Read capabilities: Input
  • UserInputService.OverrideMouseIconBehavior: Enum.OverrideMouseIconBehavior
    • Hidden
    • Roblox script security
    • Read capabilities: Input
  • UserInputService.PreferredInput: Enum.PreferredInput
    Queries the primary input type a player is using, based on anticipated user behavior.
    • Read only
    • Read capabilities: Input
    • Save only
  • UserInputService.RightBarSize: Vector2
    • Hidden
    • Read only
    • Roblox script security
    • Read capabilities: Input
  • UserInputService.StatusBarSize: Vector2
    • Hidden
    • Read only
    • Roblox script security
    • Read capabilities: Input
  • UserInputService.TouchEnabled: boolean
    Describes whether the user's device has a touch screen available.
    • Read only
    • Read capabilities: Input
    • Save only
  • UserInputService.TouchScreenEnabled: boolean
    Describes whether the user's device has a touch screen, reflecting the device's true hardware capability.
    • Read only
    • Roblox script security
    • Read capabilities: Input
    • Save only
  • UserInputService.VREnabled: boolean
    Indicates whether the user is using a virtual reality headset.
    • Read only
    • Read capabilities: Input
    • Save only
  • UserInputService.UserHeadCFrame: CFrame
    Deprecated: This item has been superseded by UserInputService:GetUserCFrame() which should be used in all new work.
    Describes the orientation and position of a user's head, if they are actively using a virtual reality headset.
    • Deprecated
    • Read only
    • Read capabilities: Input

Methods72

Inherited fromObject3
  • Get an event that fires when a given property of the object changes.
    Parameters
    ParameterDescription
    property: string
    The property to connect to.
    Returns
    TypeDescription
    RBXScriptSignal
    A signal that fires whenever the property changes.
  • Object:IsA(className: string): boolean
    Returns true if an object's class matches or inherits from a given class.
    • Custom Lua state
    • Thread safe
    Parameters
    ParameterDescription
    className: string
    The class against which the Object's class will be checked. Case-sensitive.
    Returns
    TypeDescription
    boolean
    Describes whether the Object's class matched or is a subclass of the given class.
  • Object:isA(className: string): boolean
    Deprecated: This deprecated function is a variant of Object:IsA() which should be used instead.
    • Deprecated
    • Custom Lua state
    Parameters
    Parameter
    className: string
    Returns
    Type
    boolean

    Use IsA instead.

Inherited fromInstance39
Defined byUserInputService30
  • UserInputService:CreateVirtualInput(): Object
    Creates a VirtualInput object for simulating mouse, keyboard, and pointer input.
    • Capabilities: Input
    Returns
    TypeDescription
    Object
    A new VirtualInput object, or nil if the feature is not available.
  • UserInputService:GamepadSupports(gamepadNum: Enum.UserInputType,gamepadKeyCode: Enum.KeyCode,): boolean
    Returns whether the given UserInputType gamepad supports a button corresponding with the given KeyCode.
    • Capabilities: Input
    Parameters
    ParameterDescription
    gamepadNum: Enum.UserInputType
    The UserInputType of the gamepad.
    gamepadKeyCode: Enum.KeyCode
    The KeyCode of the button in question.
    Returns
    TypeDescription
    boolean
    Whether the given gamepad supports a button corresponding with the given KeyCode.
  • UserInputService:GetConnectedGamepads(): { any }
    Returns an array of UserInputType gamepads currently connected.
    • Capabilities: Input
    Returns
    TypeDescription
    { any }
    An array of UserInputTypes corresponding with the gamepads connected to the user's device.
  • UserInputService:GetDeviceAcceleration(): InputObject
    Returns an InputObject that describes the device's current acceleration.
    • Capabilities: Input
    Returns
    TypeDescription
    InputObject
    An InputObject describing the device's current acceleration, with Position representing the acceleration force on each local device axis.
  • UserInputService:GetDeviceGravity(): InputObject
    Returns an InputObject describing the device's current gravity vector.
    • Capabilities: Input
    Returns
    TypeDescription
    InputObject
    An InputObject describing the device's current gravity vector, with Position representing the force of gravity on each local device axis.
  • UserInputService:GetDeviceLevel(): Enum.DeviceLevel
    • Roblox script security
    • Capabilities: Input
    Returns
    Type
    Enum.DeviceLevel
  • UserInputService:GetDeviceRotation(): ...any
    Returns an InputObject and a CFrame describing the device's current rotation vector.
    • Capabilities: Input
    Returns
    TypeDescription
    ...any
    A tuple containing two properties: The delta describing the amount of rotation that last happened, and the CFrame of the device's current rotation relative to its default reference frame.
  • UserInputService:GetDeviceType(): Enum.DeviceType
    • Roblox script security
    • Capabilities: Input
    Returns
    Type
    Enum.DeviceType
  • UserInputService:GetFocusedTextBox(): TextBox
    Returns the TextBox the client is currently focused on.
    • Capabilities: Input
    Returns
    TypeDescription
    TextBox
    The currently focused TextBox, or nil if no TextBox is focused.
  • UserInputService:GetGamepadConnected(gamepadNum: Enum.UserInputType): boolean
    Returns whether a gamepad with the given UserInputType is connected.
    • Capabilities: Input
    Parameters
    ParameterDescription
    gamepadNum: Enum.UserInputType
    The UserInputType of the gamepad in question.
    Returns
    TypeDescription
    boolean
    Whether a gamepad associated with UserInputType is connected.
  • UserInputService:GetGamepadState(gamepadNum: Enum.UserInputType): { Instance }
    Returns an array of InputObjects for all available inputs on the given gamepad, representing each input's last input state.
    • Capabilities: Input
    Parameters
    ParameterDescription
    gamepadNum: Enum.UserInputType
    The UserInputType corresponding with the gamepad in question.
    Returns
    TypeDescription
    { Instance }
    An array of InputObjects representing the current state of all available inputs for the given gamepad.
  • UserInputService:GetImageForKeyCode(keyCode: Enum.KeyCode): string
    Returns an image for the requested KeyCode.
    • Capabilities: Input
    Parameters
    ParameterDescription
    keyCode: Enum.KeyCode
    The KeyCode for which to fetch the associated image.
    Returns
    TypeDescription
    string
    The returned image asset ID.
  • UserInputService:GetKeysPressed(): { Instance }
    Returns an array of InputObjects associated with the keys currently being pressed down.
    • Capabilities: Input
    Returns
    TypeDescription
    { Instance }
    An array of InputObjects associated with the keys currently being pressed.
  • UserInputService:GetLastInputType(): Enum.UserInputType
    Returns the UserInputType associated with the user's most recent input.
    • Capabilities: Input
    Returns
    TypeDescription
    Enum.UserInputType
    The UserInputType associated with the user's most recent input.
  • UserInputService:GetMouseButtonsPressed(): { Instance }
    Returns an array of InputObjects associated with the mouse buttons currently being held down.
    • Capabilities: Input
    Returns
    TypeDescription
    { Instance }
    An array of InputObjects corresponding to the mouse buttons currently being currently held down.
  • UserInputService:GetMouseDelta(): Vector2
    Returns the change, in pixels, of the position of the player's Mouse in the last rendered frame. Only works if the mouse is locked.
    • Capabilities: Input
    Returns
    TypeDescription
    Vector2
    Change in movement of the mouse.
  • UserInputService:GetMouseLocation(): Vector2
    Returns the current screen location of the player's Mouse relative to the top-left corner of the screen.
    • Capabilities: Input
    Returns
    TypeDescription
    Vector2
    A Vector2 representing the current screen location of the mouse, in pixels.
  • UserInputService:GetNavigationGamepads(): { any }
    Returns an array of gamepads connected and enabled for GuiObject navigation in descending order of priority.
    • Capabilities: Input
    Returns
    TypeDescription
    { any }
    An array of UserInputTypes that can be used for navigation, in descending order of priority.
  • UserInputService:GetPasteText(): string
    • Roblox script security
    • Capabilities: Input
    Returns
    Type
    string
  • UserInputService:GetPlatform(): Enum.Platform
    • Roblox script security
    • Capabilities: Input
    Returns
    Type
    Enum.Platform
  • UserInputService:GetStringForKeyCode(keyCode: Enum.KeyCode,format: Enum.KeyCodeStringFormat? = Enum.KeyCodeStringFormat.Default,): string
    Returns a string representing a key the user should press in order to input a given KeyCode, optionally in an abbreviated format.
    • Capabilities: Input
    Parameters
    ParameterDescription
    keyCode: Enum.KeyCode
    The KeyCode to get the display string for.
    format: Enum.KeyCodeStringFormat? = Enum.KeyCodeStringFormat.Default
    An KeyCodeStringFormat value that controls the format of the returned string. Defaults to KeyCodeStringFormat.Default. Pass KeyCodeStringFormat.Abbreviated to get shortened labels suitable for compact UI such as "Bksp", "LCtrl", or "Esc".
    Returns
    TypeDescription
    string
    A string representing the key the user should press for the given key code, formatted according to the specified KeyCodeStringFormat.
  • UserInputService:GetSupportedGamepadKeyCodes(gamepadNum: Enum.UserInputType): { any }
    Returns an array of KeyCodes that the gamepad associated with the given UserInputType supports.
    • Capabilities: Input
    Parameters
    ParameterDescription
    gamepadNum: Enum.UserInputType
    The UserInputType of the gamepad.
    Returns
    TypeDescription
    { any }
    An array of KeyCodes supported by the given gamepad.
  • UserInputService:IsGamepadButtonDown(gamepadNum: Enum.UserInputType,gamepadKeyCode: Enum.KeyCode,): boolean
    Determines whether a particular button is pressed on a gamepad.
    • Capabilities: Input
    Parameters
    ParameterDescription
    gamepadNum: Enum.UserInputType
    The UserInputType of the given gamepad.
    gamepadKeyCode: Enum.KeyCode
    The KeyCode of the specified gamepad button.
    Returns
    TypeDescription
    boolean
    Whether the specified button on the given gamepad is pressed is pressed.
  • UserInputService:IsKeyDown(keyCode: Enum.KeyCode): boolean
    Returns whether the given key is currently held down.
    • Capabilities: Input
    Parameters
    ParameterDescription
    keyCode: Enum.KeyCode
    The KeyCode of the key.
    Returns
    TypeDescription
    boolean
    Whether the specified key is being held down.
  • UserInputService:IsMouseButtonPressed(mouseButton: Enum.UserInputType): boolean
    Returns whether the given mouse button is currently held down.
    • Capabilities: Input
    Parameters
    ParameterDescription
    mouseButton: Enum.UserInputType
    The UserInputType of the mouse button.
    Returns
    TypeDescription
    boolean
    Whether the given mouse button is currently held down.
  • UserInputService:IsNavigationGamepad(gamepadEnum: Enum.UserInputType): boolean
    Returns true if the specified gamepad is allowed to control navigation and selection GuiObjects.
    • Capabilities: Input
    Parameters
    ParameterDescription
    gamepadEnum: Enum.UserInputType
    The UserInputType of the specified gamepad.
    Returns
    TypeDescription
    boolean
    Whether the specified gamepad is a navigation gamepad.
  • UserInputService:RecenterUserHeadCFrame()
    Recenters the CFrame of the VR headset to the current orientation of the headset worn by the user.
    • Capabilities: Input
  • UserInputService:SendAppUISizes(statusBarSize: Vector2,navBarSize: Vector2,bottomBarSize: Vector2,rightBarSize: Vector2,)
    • Roblox script security
    • Capabilities: Input
    Parameters
    Parameter
    statusBarSize: Vector2
    navBarSize: Vector2
    bottomBarSize: Vector2
    rightBarSize: Vector2
  • UserInputService:SetNavigationGamepad(gamepadEnum: Enum.UserInputType,enabled: boolean,)
    Sets whether or not the specified gamepad can move the GuiObject navigator.
    • Capabilities: Input
    Parameters
    ParameterDescription
    gamepadEnum: Enum.UserInputType
    The UserInputType of the specified gamepad.
    enabled: boolean
    Whether the specified gamepad can move the GUI navigator.
  • UserInputService:GetUserCFrame(type: Enum.UserCFrame): CFrame
    Deprecated: Use VRService:GetUserCFrame() instead.
    Returns a CFrame describing the position and orientation of a specified virtual reality device.
    • Deprecated
    • Capabilities: Input
    Parameters
    ParameterDescription
    type: Enum.UserCFrame
    The UserCFrame corresponding to the VR device.
    Returns
    TypeDescription
    CFrame
    A CFrame describing the position and orientation of the specified VR device.

    Use GetUserCFrame instead.

Events38

Inherited fromObject1
Inherited fromInstance9
Defined byUserInputService28