Input

Simulate mouse and keyboard input in the Roblox window.

9 functionssUNC 100%Lynx 0.0.0

Input functions send real input events to the Roblox window, as if they came from your mouse and keyboard. They only take effect while Roblox is the focused window. Check with isrbxactive.

Mouse buttons

mouse1click

since 1.0.0
mouse1click(): ()

Presses and releases the left mouse button.

Example

if isrbxactive() then
mouse1click()
end

mouse1press

since 1.0.0
mouse1press(): ()

Presses the left mouse button and holds it until mouse1release is called.

Example

mouse1press()
task.wait(0.5)
mouse1release()

mouse1release

since 1.0.0
mouse1release(): ()

Releases the left mouse button.

Example

mouse1release()

mouse2click

since 1.0.0
mouse2click(): ()

Presses and releases the right mouse button. mouse2press and mouse2release hold and release it separately.

Example

mouse2click()

Mouse movement

mousemoverel

since 1.0.0
mousemoverel(x: number, y: number): ()

Moves the cursor by x and y pixels from where it is now.

Parameters

xnumber
Horizontal distance. Positive moves right.
ynumber
Vertical distance. Positive moves down.

Example

for _ = 1, 20 do
mousemoverel(5, 0)
task.wait()
end

mousemoveabs

since 1.0.0
mousemoveabs(x: number, y: number): ()

Moves the cursor to x, y, in pixels from the top-left of the Roblox window's content area.

Parameters

xnumber
Horizontal position.
ynumber
Vertical position.

Example

local viewport = workspace.CurrentCamera.ViewportSize
mousemoveabs(viewport.X / 2, viewport.Y / 2)

Keyboard

keypress

since 1.0.0
keypress(keycode: number): ()

Presses the key with the Windows virtual-key code keycode and holds it until keyrelease.

Parameters

keycodenumber
A virtual-key code. See the table below.

Example

local VK_SPACE = 0x20
keypress(VK_SPACE)
task.wait(0.1)
keyrelease(VK_SPACE)

keyrelease

since 1.0.0
keyrelease(keycode: number): ()

Releases the key with the virtual-key code keycode. Pair every keypress with one.

Parameters

keycodenumber
A virtual-key code.

Example

keyrelease(0x57) -- W

Common key codes

KeyCode
A to Z0x41 to 0x5A
0 to 90x30 to 0x39
Space0x20
Enter0x0D
Shift0x10
Ctrl0x11
Esc0x1B
Left, Up, Right, Down0x25, 0x26, 0x27, 0x28
F1 to F120x70 to 0x7B

Window

isrbxactive

since 1.0.0
isrbxactive(): boolean

Returns whether the Roblox window is focused. Input functions do nothing while it isn't.

Also available as isgameactive.

Returns

boolean

true when Roblox has focus.

Example

while not isrbxactive() do
task.wait(0.25)
end
print("Roblox is focused")