InputObject
Describes an input type, state, position, and change.
Behavior
InputObject describes input delivered by
InputService. Check UserInputType before reading
fields whose meaning depends on the device.
Summary
The runtime type name of the input value.
The position change since the previous input event.
The key or gamepad button as an Enum.KeyCode.
The name of the input value.
The input position.
The input lifecycle state: beginning, change, or end.
The input category, such as keyboard, mouse button, touch, or gamepad.
IsA(string): booleanReturns whether the input value matches the supplied type name.
Properties
ClassName
InputObject.ClassName: stringThe runtime type name of the input value.
Delta
InputObject.Delta: Vector3The position change since the previous input event. Use this for relative motion when the pointer is locked.
KeyCode
InputObject.KeyCode: EnumItemThe key or gamepad button as an Enum.KeyCode. Non-button input uses Unknown.
Name
InputObject.Name: stringThe name of the input value.
Position
InputObject.Position: Vector3The input position. Pointer and touch input use screen coordinates; the third component carries scroll input. Thumbstick input uses axis deflection.
UserInputState
InputObject.UserInputState: EnumItemThe input lifecycle state: beginning, change, or end.
UserInputType
InputObject.UserInputType: EnumItemThe input category, such as keyboard, mouse button, touch, or gamepad.
Methods
IsA
InputObject:IsA(string): booleanReturns whether the input value matches the supplied type name.
Operators
__tostring · __type
Example
local InputService = game:GetService("InputService")
InputService.Began:Connect(function(input, gameProcessed)
if not gameProcessed then
print(input.UserInputType)
end
end)Used by
Frame · ImageButton · ImageLabel · InputService · SceneFrame · ScrollingFrame · TextBox · TextButton · TextLabel