Reference/Classes/UserInputService
Class

UserInputService

since 1.7.0b-alpha

Reports user input from the keyboard and mouse, and exposes events for input transitions.

InheritsInstance

Properties

3
NameTypeAccessDescription
InputBeganEventread

Fired when the user begins interacting via a human-interface device (keyboard or mouse). The connection receives an InputObject.

since 1.7.0b-alphaRoblox ↗
InputEndedEventread

Fired when the user stops interacting via a human-interface device. The connection receives an InputObject.

since 1.7.0b-alphaRoblox ↗
InputChangedEventread

Fired when the user's mouse cursor moves while the Roblox or Madius window is focused. The connection receives an InputObject.

since 1.7.0b-alphaRoblox ↗

Methods

3

#UserInputService:IsKeyDown(keyCode: KeyCode) → boolean

since 1.7.0b-alpha

Returns whether keyCode is currently held by the user on their physical keyboard.

Parameters

keyCodeKeyCode

The key to test.

Errors

  • VMException read failure -- Failed to read backing memory while executing this method.

#UserInputService:IsMouseButtonPressed(mouseButton: KeyCode) → boolean

since 1.7.0b-alpha

Returns whether mouseButton is currently held by the user on their physical mouse. Use Enum.KeyCode.LeftButton, RightButton or MiddleButton.

Parameters

mouseButtonKeyCode

The mouse button to test.

Errors

  • VMException read failure -- Failed to read backing memory while executing this method.

#UserInputService:GetMouseLocation() → Vector2

since 1.7.0b-alpha

Returns the cursor position in screen coordinates. Updated only if either Roblox or Madius window is focused.

Errors

  • VMException read failure -- Failed to read backing memory while executing this method.