InputObject
An object created when an input begins that describes a particular user input.
Memory category | Instances |
---|
Member index 6
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:
- ContextActionService, which passes an InputObject to bound action-handling functions
- UserInputService, whose events and functions often use InputObject
- GuiObject, whose events related to user input use InputObject
History 23
- 553 Change Default of UserInputType from to None
- 553 Change Default of UserInputState from to None
- 553 Change Default of Position from to Vector3(0, 0, 0)
- 553 Change Default of KeyCode from to Unknown
- 553 Change Default of Delta from to Vector3(0, 0, 0)
- 486 Change ThreadSafety of UserInputType from ReadOnly to ReadSafe
- 486 Change ThreadSafety of UserInputState from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Position from ReadOnly to ReadSafe
- 486 Change ThreadSafety of KeyCode from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Delta from ReadOnly to ReadSafe
- 462 Change ThreadSafety of IsModifierKeyDown from to Unsafe
- 462 Change ThreadSafety of UserInputType from to ReadOnly
- 462 Change ThreadSafety of UserInputState from to ReadOnly
- 462 Change ThreadSafety of Position from to ReadOnly
- 462 Change ThreadSafety of KeyCode from to ReadOnly
- 462 Change ThreadSafety of Delta from to ReadOnly
- 408 Add IsModifierKeyDown
- 158 Add Delta
- 133 Add UserInputType
- 133 Add UserInputState
- 133 Add Position
- 133 Add KeyCode
- 133 Add InputObject
Members 6
Delta
Type | Default | |
---|---|---|
Vector3 | 0, 0, 0 |
A Vector3 describing the Delta (change) between mouse/joystick movements.
This is useful when used with the input's position to track the position and movement of the user's mouse/joystick, 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.
See also:
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false |
IsModifierKeyDown
Parameters (1) | ||
---|---|---|
modifierKey | ModifierKey | |
Returns (1) | ||
bool |
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of IsModifierKeyDown from to Unsafe
- 408 Add IsModifierKeyDown
KeyCode
Type | Default | |
---|---|---|
KeyCode | Unknown |
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.
Enums
Name | Value | Description |
---|---|---|
Unknown | 0 | |
Backspace | 8 | |
Tab | 9 | |
Clear | 12 | |
Return | 13 | |
Pause | 19 | |
Escape | 27 | |
Space | 32 | |
QuotedDouble | 34 | |
Hash | 35 | |
Dollar | 36 | |
Percent | 37 | |
Ampersand | 38 | |
Quote | 39 | |
LeftParenthesis | 40 | |
RightParenthesis | 41 | |
Asterisk | 42 | |
Plus | 43 | |
Comma | 44 | |
Minus | 45 | |
Period | 46 | |
Slash | 47 | |
Zero | 48 | |
One | 49 | |
Two | 50 | |
Three | 51 | |
Four | 52 | |
Five | 53 | |
Six | 54 | |
Seven | 55 | |
Eight | 56 | |
Nine | 57 | |
Colon | 58 | |
Semicolon | 59 | |
LessThan | 60 | |
Equals | 61 | |
GreaterThan | 62 | |
Question | 63 | |
At | 64 | |
LeftBracket | 91 | |
BackSlash | 92 | |
RightBracket | 93 | |
Caret | 94 | |
Underscore | 95 | |
Backquote | 96 | |
A | 97 | |
B | 98 | |
C | 99 | |
D | 100 | |
E | 101 | |
F | 102 | |
G | 103 | |
H | 104 | |
I | 105 | |
J | 106 | |
K | 107 | |
L | 108 | |
M | 109 | |
N | 110 | |
O | 111 | |
P | 112 | |
Q | 113 | |
R | 114 | |
S | 115 | |
T | 116 | |
U | 117 | |
V | 118 | |
W | 119 | |
X | 120 | |
Y | 121 | |
Z | 122 | |
LeftCurly | 123 | |
Pipe | 124 | |
RightCurly | 125 | |
Tilde | 126 | |
Delete | 127 | |
KeypadZero | 256 | |
KeypadOne | 257 | |
KeypadTwo | 258 | |
KeypadThree | 259 | |
KeypadFour | 260 | |
KeypadFive | 261 | |
KeypadSix | 262 | |
KeypadSeven | 263 | |
KeypadEight | 264 | |
KeypadNine | 265 | |
KeypadPeriod | 266 | |
KeypadDivide | 267 | |
KeypadMultiply | 268 | |
KeypadMinus | 269 | |
KeypadPlus | 270 | |
KeypadEnter | 271 | |
KeypadEquals | 272 | |
Up | 273 | |
Down | 274 | |
Right | 275 | |
Left | 276 | |
Insert | 277 | |
Home | 278 | |
End | 279 | |
PageUp | 280 | |
PageDown | 281 | |
LeftShift | 304 | |
RightShift | 303 | |
LeftMeta | 310 | |
RightMeta | 309 | |
LeftAlt | 308 | |
RightAlt | 307 | |
LeftControl | 306 | |
RightControl | 305 | |
CapsLock | 301 | |
NumLock | 300 | |
ScrollLock | 302 | |
LeftSuper | 311 | |
RightSuper | 312 | |
Mode | 313 | |
Compose | 314 | |
Help | 315 | |
316 | ||
SysReq | 317 | |
Break | 318 | |
Menu | 319 | |
Power | 320 | |
Euro | 321 | |
Undo | 322 | |
F1 | 282 | |
F2 | 283 | |
F3 | 284 | |
F4 | 285 | |
F5 | 286 | |
F6 | 287 | |
F7 | 288 | |
F8 | 289 | |
F9 | 290 | |
F10 | 291 | |
F11 | 292 | |
F12 | 293 | |
F13 | 294 | |
F14 | 295 | |
F15 | 296 | |
World0 | 160 | |
World1 | 161 | |
World2 | 162 | |
World3 | 163 | |
World4 | 164 | |
World5 | 165 | |
World6 | 166 | |
World7 | 167 | |
World8 | 168 | |
World9 | 169 | |
World10 | 170 | |
World11 | 171 | |
World12 | 172 | |
World13 | 173 | |
World14 | 174 | |
World15 | 175 | |
World16 | 176 | |
World17 | 177 | |
World18 | 178 | |
World19 | 179 | |
World20 | 180 | |
World21 | 181 | |
World22 | 182 | |
World23 | 183 | |
World24 | 184 | |
World25 | 185 | |
World26 | 186 | |
World27 | 187 | |
World28 | 188 | |
World29 | 189 | |
World30 | 190 | |
World31 | 191 | |
World32 | 192 | |
World33 | 193 | |
World34 | 194 | |
World35 | 195 | |
World36 | 196 | |
World37 | 197 | |
World38 | 198 | |
World39 | 199 | |
World40 | 200 | |
World41 | 201 | |
World42 | 202 | |
World43 | 203 | |
World44 | 204 | |
World45 | 205 | |
World46 | 206 | |
World47 | 207 | |
World48 | 208 | |
World49 | 209 | |
World50 | 210 | |
World51 | 211 | |
World52 | 212 | |
World53 | 213 | |
World54 | 214 | |
World55 | 215 | |
World56 | 216 | |
World57 | 217 | |
World58 | 218 | |
World59 | 219 | |
World60 | 220 | |
World61 | 221 | |
World62 | 222 | |
World63 | 223 | |
World64 | 224 | |
World65 | 225 | |
World66 | 226 | |
World67 | 227 | |
World68 | 228 | |
World69 | 229 | |
World70 | 230 | |
World71 | 231 | |
World72 | 232 | |
World73 | 233 | |
World74 | 234 | |
World75 | 235 | |
World76 | 236 | |
World77 | 237 | |
World78 | 238 | |
World79 | 239 | |
World80 | 240 | |
World81 | 241 | |
World82 | 242 | |
World83 | 243 | |
World84 | 244 | |
World85 | 245 | |
World86 | 246 | |
World87 | 247 | |
World88 | 248 | |
World89 | 249 | |
World90 | 250 | |
World91 | 251 | |
World92 | 252 | |
World93 | 253 | |
World94 | 254 | |
World95 | 255 | |
ButtonX | 1000 | |
ButtonY | 1001 | |
ButtonA | 1002 | |
ButtonB | 1003 | |
ButtonR1 | 1004 | |
ButtonL1 | 1005 | |
ButtonR2 | 1006 | |
ButtonL2 | 1007 | |
ButtonR3 | 1008 | |
ButtonL3 | 1009 | |
ButtonStart | 1010 | |
ButtonSelect | 1011 | |
DPadLeft | 1012 | |
DPadRight | 1013 | |
DPadUp | 1014 | |
DPadDown | 1015 | |
Thumbstick1 | 1016 | |
Thumbstick2 | 1017 |
See also:
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false |
Position
Type | Default | |
---|---|---|
Vector3 | 0, 0, 0 |
This property describes a Vector3 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).
For KeyCode input, this indicates the position of the player's Mouse.
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.
See also
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false |
UserInputState
Type | Default | |
---|---|---|
UserInputState | None |
UserInputState 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. See the enum page for a list of all possible values for this property.
See also:
Thread safety | ReadSafe |
---|---|
Category | State |
Loaded/Saved | false |
History 4
- 553 Change Default of UserInputState from to None
- 486 Change ThreadSafety of UserInputState from ReadOnly to ReadSafe
- 462 Change ThreadSafety of UserInputState from to ReadOnly
- 133 Add UserInputState
UserInputType
Type | Default | |
---|---|---|
UserInputType | None |
UserInputType is a property that describes for what kind of input this InputObject represents, such as mouse, keyboard, touch or gamepad input. It uses the enum of the same name, UserInputType. See the enum page for a list of all possible values for this property.
See also:
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false |
History 4
- 553 Change Default of UserInputType from to None
- 486 Change ThreadSafety of UserInputType from ReadOnly to ReadSafe
- 462 Change ThreadSafety of UserInputType from to ReadOnly
- 133 Add UserInputType