Class · inherits Instance
InputObject
An object created when an input begins that describes a particular user input.
About InputObject
An InputObject represents a single user input, such as mouse movement,
touches, key presses and more. It is created when an input begins.
The properties of this object vary according the
UserInputType. Each kind of input will
undergo various changes to its
UserInputState. During the lifetime of an
input, other properties which further describe the input may change, such as
Position and Delta.
Keyboard and gamepad button presses will have the
KeyCode property set.
Once created at the beginning of an input, the same object persists and is
updated until the input ends. As a result, you can track the object's changes
using the Changed event as the user changes the input
in question. You can also place these objects into a list of active inputs
track and interact with the object after it's creation by an event such as
UserInputService.InputBegan. This is mostly useful for touch events,
as each touch point will have a separate InputObject.
See also UserInputService whose events and functions often use
InputObject, and GuiObject whose events related to user input use
InputObject.
Properties 5
Delta
: Vector3AVector3describing the delta between input movements.A
Vector3describing the delta (change) between input movements.This is useful when used with the input's
Positionto track the position and movement of the user's input, such as when you're creating custom movement or camera scripts. Consider tracking input object changes using theObject.Changedevent or when user input changes via events such asUserInputService.InputChangedandGuiObject.InputChanged.Note that an
InputObjectcorresponding toUserInputType.MouseButton1(left click) andUserInputType.MouseButton2(right click) supplied from anInputBegancallback will not have itsDeltaorPositionupdated once created, except for when the mouse input ends. In order to get updated deltas for mouse inputs, you must instead reference anInputObjectfrom anInputChangedcallback, or callGetMouseDelta(). However, anyInputObjectscorresponding to touch inputs will have their delta and position updated every frame throughout their lifetime.KeyCode
: KeyCodeContains an Enum that describes the kind of input used.Contains a
KeyCodeenum that describes what kind of input was used. For types of input like keyboard, this describes what key was pressed. For inputs like the mouse, this provides no additional information.Position
: Vector3AVector3describing the positional value of this input.A
Vector3describing the positional value of this input.For mouse and touch input, this is the screen position of the mouse/touch, described in the X and Y components. The inset applied to GUI elements (such as from the top bar) is accounted for in the position. For the mouse wheel input, the Z component describes whether the wheel was moved forward (positive number), backwards (negative number), or not at all (
0).Note that an
InputObjectcorresponding toUserInputType.MouseButton1(left click) andUserInputType.MouseButton2(right click) supplied from anInputBegancallback will not have itsDeltaorPositionupdated once created, except for when the mouse input ends. In order to get updated positions for mouse inputs, you must instead reference anInputObjectfrom anInputChangedcallback, or callGetMouseLocation(). However, anyInputObjectscorresponding to touch inputs will have their delta and position updated every frame throughout their lifetime.UserInputState
: UserInputStateDescribes the state of an input being performed, following a specific flow depending on theUserInputType.This property describes the state of an input being performed, following a specific flow depending on the
UserInputType. It uses the enum of the same name,UserInputState.UserInputType
: UserInputTypeDescribes the kind of input being performed (mouse, keyboard, gamepad, touch, etc.).This property describes the kind of input this
InputObjectrepresents, such as mouse, keyboard, touch, or gamepad input. It uses the enum of the same name,UserInputType.
Methods 1
IsModifierKeyDown
(modifierKey: ModifierKey) → booleanReturns whether the passed in modifier key is down.Returns
trueif the passed inmodifierKeysuch asShiftis being held down.
InputObject also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.