Reference API Roblox

Engine API

Website

Related

Reference API Roblox

InputObject

An object created when an input begins that describes a particular user input.

This class is not creatable. Instances of this class cannot be created with Instance.new.
Tags: [NotCreatable]

Member index 6

HistoryMember
553Delta: Vector3
553KeyCode: KeyCode
553Position: Vector3
553UserInputState: UserInputState
553UserInputType: UserInputType
462IsModifierKeyDown(modifierKey: ModifierKey): bool
inherited from Instance
553Archivable: bool
670Capabilities: SecurityCapabilities
553Name: string
553Parent: Instance
670Sandboxed: bool
680UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
486GetDescendants(): Array
486GetFullName(): string
641GetStyled(name: string): Variant
657GetStyledPropertyChangedSignal(property: string): RBXScriptSignal
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
664IsPropertyModified(property: string): bool
573Remove(): null
576RemoveTag(tag: string): null
664ResetPropertyToDefault(property: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
648children(): Instances
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
648getChildren(): Instances
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
657StyledPropertiesChanged()
553childAdded(child: Instance)
inherited from Object
647ClassName: string
647className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
650isA(className: string): bool
647Changed(property: string)

Description

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.

History 23

Members 6

Delta

TypeDefault
Vector30, 0, 0

A Vector3 describing the delta (change) between input movements.

This is useful when used with the input's Position to 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 the Object.Changed event or when user input changes via events such as UserInputService.InputChanged and GuiObject.InputChanged.

Note that an InputObject corresponding to UserInputType.MouseButton1 (left click) and UserInputType.MouseButton2 (right click) supplied from an InputBegan callback will not have its Delta or Position updated once created, except for when the mouse input ends. In order to get updated deltas for mouse inputs, you must instead reference an InputObject from an InputChanged callback, or call GetMouseDelta(). However, any InputObjects corresponding to touch inputs will have their delta and position updated every frame throughout their lifetime.

History 4

IsModifierKeyDown

Parameters (1)
modifierKeyModifierKey
Returns (1)
bool

Returns true if the passed in modifierKey such as Shift is being held down.

History 2

KeyCode

TypeDefault
KeyCodeUnknown

Contains a KeyCode enum 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.

History 4

Position

TypeDefault
Vector30, 0, 0

A Vector3 describing 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 (1), backwards (-1), or not at all (0).

Note that an InputObject corresponding to UserInputType.MouseButton1 (left click) and UserInputType.MouseButton2 (right click) supplied from an InputBegan callback will not have its Delta or Position updated once created, except for when the mouse input ends. In order to get updated positions for mouse inputs, you must instead reference an InputObject from an InputChanged callback, or call GetMouseLocation(). However, any InputObjects corresponding to touch inputs will have their delta and position updated every frame throughout their lifetime.

History 4

UserInputState

TypeDefault
UserInputStateNone

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.

History 4

UserInputType

TypeDefault
UserInputTypeNone

This property describes the kind of input this InputObject represents, such as mouse, keyboard, touch, or gamepad input. It uses the enum of the same name, UserInputType.

History 4

Settings