Library

input

table

Synthetic input: keyboard clicks, mouse clicks, mouse movement (instant and tweened), and queries against the host input state.

Functions

15

#input.key_down(key: number|KeyCode) → InputState

since 1.2.0-alpha

Sends a key-down event for the given virtual key code key. Errors if the provided key is invalid.

Aliaseskeydown

Parameters

keynumber|KeyCode

Virtual key code.

#input.key_up(key: number|KeyCode) → InputState

since 1.2.0-alpha

Sends a key-up event for the given virtual key code key. Errors if the provided key is invalid.

Aliaseskeyup

Parameters

keynumber|KeyCode

Virtual key code.

#input.key_click(key: number|KeyCode) → InputState

yieldssince 1.2.0-alpha

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.

Aliaseskeyclick

Parameters

keynumber|KeyCode

Virtual key code.

#input.is_key_down(key: number|KeyCode) → boolean

since 1.2.0-alpha

Returns whether the given virtual key code key is currently held down by the input library.

Aliasesiskeydown

Parameters

keynumber|KeyCode

Virtual key code.

#input.mouse_down(button: number|KeyCode) → InputState

since 1.2.0-alpha

Sends a mouse button-down event. button must be Enum.KeyCode.LeftButton, RightButton, or MiddleButton. Errors if the provided button is invalid.

Aliasesmousedown

Parameters

buttonnumber|KeyCode

Virtual mouse button code.

#input.mouse_up(button: number|KeyCode) → InputState

since 1.2.0-alpha

Sends a mouse button-up event. Errors if the provided button is invalid.

Aliasesmouseup

Parameters

buttonnumber|KeyCode

Virtual mouse button code.

#input.is_mouse_down(button: number|KeyCode) → boolean

since 1.2.0-alpha

Returns whether button is currently held down by the input library.

Aliasesismousedown

Parameters

buttonnumber|KeyCode

Virtual mouse button code.

#input.mouse_click(button: number|KeyCode, count: number?) → InputState

yieldssince 1.2.0-alpha

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.

Aliasesmouseclick

Parameters

buttonnumber|KeyCode

Virtual mouse button code.

countnumber?

Number of clicks (default 2).

#input.mouse_move_absolute(position: Vector2) → InputState

since 1.2.0-alpha

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".

Aliasesmousemoveabsolute

Parameters

positionVector2

Absolute screen position to move to.

#input.mouse_move_relative(offset: Vector2) → InputState

since 1.2.0-alpha

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.

Aliasesmousemoverelative

Parameters

offsetVector2

Relative offset to move by.

#input.mouse_move_tween(target: Vector2, duration: number) → InputState

yieldssince 1.2.0-alpha

Smoothly moves the cursor to target over duration seconds using linear interpolation. Yields until the movement completes. Errors if duration is not positive.

Aliasesmousemovetween

Parameters

targetVector2

Target screen position.

durationnumber

Duration of the movement in seconds.

#input.mouse_move_instance(instance: GuiObject) → InputState

since 1.2.0-alpha

Instantly moves the cursor to the center of the GuiObject instance. Errors if the instance has no absolute position.

Aliasesmousemoveinstance

Parameters

instanceGuiObject

GuiObject to move to.

#input.mouse_move_instance_tween(instance: GuiObject, duration: number) → InputState

yieldssince 1.2.0-alpha

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.

Aliasesmousemoveinstancetween

Parameters

instanceGuiObject

GuiObject to move to.

durationnumber

Duration of the movement in seconds.

#input.mouse_scroll(delta: number) → InputState

since 1.2.0-alpha

Sends a mouse wheel scroll event. delta is in wheel ticks; positive scrolls up, negative scrolls down.

Aliasesmousescroll

Parameters

deltanumber

Scroll amount in wheel ticks.

Errors

  • LuaError invalid gui object -- The supplied GuiObject does not expose AbsolutePosition or AbsoluteSize.

#input.is_window_focused() → boolean

since 1.2.0-alpha

Returns whether the Roblox window is currently the foreground window.

Aliasesiswindowfocused