Skip to content

UserInputService

UserInputService receives keyboard and other player input on the client. Get it through game:GetService("UserInputService") in a LocalScript.

Summary

Events

Events

InputBegan

Signal

UserInputService.InputBegan

Fires when input begins. The callback receives an InputObject; its KeyCode can be compared with an Enum.KeyCode item.

local input = game:GetService("UserInputService")
input.InputBegan:Connect(function(inputObject)
if inputObject.KeyCode == Enum.KeyCode.E then
print("E was pressed")
end
end)

InputEnded

Signal

UserInputService.InputEnded

Exposed signal for input ending.

Vortex Studio 0.3.4 notes

InputBegan:Once and InputBegan:Wait both delivered a right-mouse-button input in a LocalScript. A normal server Script has no usable UserInputService. Ordinary InputBegan:Connect also delivered keyboard keys (S, A, W, and Space) and mouse buttons. Keyboard events carried their KeyCode; mouse buttons used Enum.KeyCode.Unknown. Both gameProcessed=false and true were observed.

IsKeyDown is available: it returned true for the keyboard key currently being pressed and false for mouse-button events. The tested 0.3.4 client reported KeyboardEnabled=true, MouseEnabled=true, GamepadEnabled=false, and TouchEnabled=false.

InputEnded is connectable in a LocalScript and delivered both keyboard and mouse-button releases. InputChanged reads as nil and cannot be connected. GetMouseLocation is unavailable, while MouseBehavior and MouseIconEnabled read as nil. These results were revalidated in 0.3.4.