Roblox Wiki
Roblox Wiki
Advertisement
Roblox Wiki

The user's input can be accessed in three ways:

  • through a InputObject which is passed by the events InputBegan, InputChanged and InputEnded of either the UserInputService light iconUserInputService dark iconUserInputService service or a UI element (GuiObject)
  • binding a UserInputType through the Light service iconDark service iconContextActionService service
  • through the Mouse object which can be accessed either by the GetMouse function of a Player light iconPlayer dark iconPlayer, the GetMouse function of a Plugin, or the Equipped event of a Tool light iconTool dark iconTool (this is considered the legacy way of accessing the mouse and keyboard input, and is considered superseded by the others as it does not account for other inputs such as the touch input)

History[]

The UserInputService light iconUserInputService dark iconUserInputService and Light service iconDark service iconContextActionService services were introduced sometime in 2014. Previously, the Mouse class was the primary way of accessing mouse and keyboard input.

At some point, the KeyUp and KeyDown events of the Mouse class were deprecated in favor of the new services.

UserInputType[]

The UserInputType enum represents a type of user input. There are 21 UserInputTypes:

  • Mouse inputs:
    • MouseButton1 (defaulted to left-click)
    • MouseButton2 (defaulted to right-click)
    • MouseButton3 (defaulted to middle-click)
    • MouseWheel (refers to scrolling)
    • MouseMovement
  • Touch (refers to touchscreen input)
  • Keyboard
  • Focus (refers to the client regaining focus of the Roblox window)
  • Mobile inputs:
    • Accelerometer (represents the device's acceleration in the real world)
    • Gyro (represents the device's orientation and angular velocity in the real world)
  • Gamepad1 to Gamepad8 (represents each USB gamepad that is connected)
  • TextInput (refers to input of Text into a TextBox light iconTextBox dark iconTextBox)
  • InputMethod (refers to Text input from an input method editor)
  • None

InputObject[]

User inputs are represented as InputObjects. InputObjects are passed by the events InputBegan, InputChanged and InputEnded of either the UserInputService light iconUserInputService dark iconUserInputService service or a UI element (GuiObject). InputObjects have the UserInputType property.

Binding[]

UserInputTypes can be binded through the Light service iconDark service iconContextActionService service.

Mouse class[]

The Mouse is a class that represents the user's mouse (although it has keyboard input events KeyUp and KeyDown) and has two sub-classes: PlayerMouse and PluginMouse light iconPluginMouse dark iconPluginMouse.

The Mouse object is passed by the Equipped event of a Tool light iconTool dark iconTool. The PlayerMouse is accessed through the GetMouse function of a Player light iconPlayer dark iconPlayer. This function can only be called from the client. The PluginMouse light iconPluginMouse dark iconPluginMouse is accessed through the GetMouse function of the Plugin object.

External links[]


Advertisement