Skip to content

Input

Functions for simulating mouse and keyboard input.

WARNING

These functions simulate real hardware input. The game window should be active for them to work. Use isrbxactive() to check.

Mouse Functions

mouse1click

Simulates a left mouse button click (press + release).

lua
mouse1click() -> void

mouse1press

Simulates pressing the left mouse button down.

lua
mouse1press(x: number?, y: number?) -> void
ParameterTypeDescription
xnumber?Optional X position
ynumber?Optional Y position

mouse1release

Simulates releasing the left mouse button.

lua
mouse1release(x: number?, y: number?) -> void
ParameterTypeDescription
xnumber?Optional X position
ynumber?Optional Y position

mouse2click

Simulates a right mouse button click (press + release).

lua
mouse2click() -> void

mouse2press

Simulates pressing the right mouse button down.

lua
mouse2press(x: number?, y: number?) -> void
ParameterTypeDescription
xnumber?Optional X position
ynumber?Optional Y position

mouse2release

Simulates releasing the right mouse button.

lua
mouse2release(x: number?, y: number?) -> void
ParameterTypeDescription
xnumber?Optional X position
ynumber?Optional Y position

mousemoverel

Moves the mouse cursor by a relative offset from its current position.

lua
mousemoverel(x: number, y: number) -> void
ParameterTypeDescription
xnumberHorizontal offset in pixels
ynumberVertical offset in pixels

mousemoveabs

Moves the mouse cursor to an absolute screen position.

lua
mousemoveabs(x: number, y: number) -> void
ParameterTypeDescription
xnumberAbsolute X position
ynumberAbsolute Y position

mousescroll

Simulates scrolling the mouse wheel.

lua
mousescroll(forward: boolean) -> void
ParameterTypeDescription
forwardbooleantrue to scroll up, false to scroll down

Keyboard Functions

keypress

Simulates pressing a keyboard key down.

lua
keypress(key: KeyCode | number) -> void
ParameterTypeDescription
keyKeyCode | numberThe key to press (Enum.KeyCode or virtual key code)

keyrelease

Simulates releasing a keyboard key.

lua
keyrelease(key: KeyCode | number) -> void
ParameterTypeDescription
keyKeyCode | numberThe key to release

Example

lua
-- Simulate pressing 'W' for 1 second
if isrbxactive() then
    keypress(0x57) -- W key
    task.wait(1)
    keyrelease(0x57)
end

-- Move mouse to center and click
mousemoveabs(500, 400)
task.wait(0.1)
mouse1click()