#input.key_down(key: number|KeyCode) → InputState
Sends a key-down event for the given virtual key code key. Errors if the provided key is invalid.
keydownParameters
| key | number|KeyCode | Virtual key code. |
Synthetic input: keyboard clicks, mouse clicks, mouse movement (instant and tweened), and queries against the host input state.
Sends a key-down event for the given virtual key code key. Errors if the provided key is invalid.
keydown| key | number|KeyCode | Virtual key code. |
Sends a key-up event for the given virtual key code key. Errors if the provided key is invalid.
keyup| key | number|KeyCode | Virtual key code. |
Sends a key-down, yields ~16 ms, then sends a key-up for key. The Lua coroutine is suspended while the wait happens; the VM is free to run other work in the meantime. Errors if the provided key is invalid.
keyclick| key | number|KeyCode | Virtual key code. |
Returns whether the given virtual key code key is currently held down by the input library.
iskeydown| key | number|KeyCode | Virtual key code. |
Sends a mouse button-down event. button must be Enum.KeyCode.LeftButton, RightButton, or MiddleButton. Errors if the provided button is invalid.
mousedown| button | number|KeyCode | Virtual mouse button code. |
Sends a mouse button-up event. Errors if the provided button is invalid.
mouseup| button | number|KeyCode | Virtual mouse button code. |
Returns whether button is currently held down by the input library.
ismousedown| button | number|KeyCode | Virtual mouse button code. |
Clicks button a total of count times (default 2). Yields the Lua coroutine for the duration; clicks use a ~10 ms press hold and ~50 ms inter-click gap. Errors if the provided button is invalid or count is not positive.
mouseclick| button | number|KeyCode | Virtual mouse button code. |
| count | number? | Number of clicks (default 2). |
Moves the cursor to the absolute screen position specified by position. Uses MOUSEEVENTF_ABSOLUTE so the final pixel is exact, regardless of "Enhance pointer precision".
mousemoveabsolute| position | Vector2 | Absolute screen position to move to. |
Moves the cursor by offset pixels relative to its current position. Internally resolves to an absolute move from the current cursor position to avoid pointer-ballistics drift.
mousemoverelative| offset | Vector2 | Relative offset to move by. |
Smoothly moves the cursor to target over duration seconds using linear interpolation. Yields until the movement completes. Errors if duration is not positive.
mousemovetween| target | Vector2 | Target screen position. |
| duration | number | Duration of the movement in seconds. |
Instantly moves the cursor to the center of the GuiObject instance. Errors if the instance has no absolute position.
mousemoveinstance| instance | GuiObject | GuiObject to move to. |
Smoothly moves the cursor to the center of the GuiObject instance over duration seconds. Yields until the movement completes. Errors if duration is not positive or the instance has no absolute position.
mousemoveinstancetween| instance | GuiObject | GuiObject to move to. |
| duration | number | Duration of the movement in seconds. |
Sends a mouse wheel scroll event. delta is in wheel ticks; positive scrolls up, negative scrolls down.
mousescroll| delta | number | Scroll amount in wheel ticks. |
Returns whether the Roblox window is currently the foreground window.
iswindowfocused