Skip to content

Input

The Input library provides functions for simulating keyboard and mouse input in the Roblox window. These functions are only callable if Roblox's window is in the users focus.

Window Activity Check

iswindowactive() isrbxactive() isgameactive()

These functions are aliases and check if the Roblox window is currently active.

Returns: boolean - true if the Roblox window is active, false otherwise.

if iswindowactive() then
    print("Roblox window is active")
end

Keyboard Functions

You can find a list of keycodes here: https://learn.microsoft.com/en-gb/windows/win32/inputdev/virtual-key-codes?redirectedfrom=MSDN

keypress(keyCode)

Simulates pressing a key.

  • keyCode: The virtual key code of the key to press.
keypress(0x41)  -- Press 'A' key

keytap(keyCode)

Simulates tapping (pressing and releasing) a key.

  • keyCode: The virtual key code of the key to tap.
keytap(0x42)  -- Tap 'B' key

keyrelease(keyCode)

Simulates releasing a key.

  • keyCode: The virtual key code of the key to release.
keyrelease(0x43)  -- Release 'C' key

Mouse Functions

mouse1click()

Simulates a left mouse button click.

mouse1click()

mouse1press()

Simulates pressing the left mouse button.

mouse1press()

mouse1release()

Simulates releasing the left mouse button.

mouse1release()

mouse2click()

Simulates a right mouse button click.

mouse2click()

mouse2press()

Simulates pressing the right mouse button.

mouse2press()

mouse2release()

Simulates releasing the right mouse button.

mouse2release()

mousemoveabs(x, y)

Moves the mouse cursor to absolute screen coordinates.

  • x: The x-coordinate.
  • y: The y-coordinate.
mousemoveabs(100, 200)

mousemoverel(dx, dy)

Moves the mouse cursor relative to its current position.

  • dx: The change in x-coordinate.
  • dy: The change in y-coordinate.
mousemoverel(10, -5)

mousescroll(delta)

Simulates scrolling the mouse wheel.

  • delta: The amount to scroll. Positive values scroll up, negative values scroll down.
mousescroll(120)  -- Scroll up
mousescroll(-120)  -- Scroll down

Example usage:

if iswindowactive() then
    keypress(0x57)  -- Press 'W' key
    wait(1)
    keyrelease(0x57)  -- Release 'W' key

    mousemoverel(0, 100)  -- Move mouse 100 pixels down
    mouse1click()  -- Perform a left-click
end