Skip to content

input

Reads physical keyboard/mouse state from raw evdev devices and injects synthetic key/mouse events via a virtual uinput device, gated to when Sober is the focused window.

input.Available() -> boolean

Returns true if at least one physical keyboard or mouse evdev device was discovered.

if input.Available() then print("input devices found") end

input.Poll()

Polls all discovered evdev devices once, updating held-key state and press/release edges.

input.Poll()

input.Mouse1Down() -> boolean

Returns true while the left mouse button is physically held down and Sober is focused.

if input.Mouse1Down() then print("LMB held") end

input.Mouse2Down() -> boolean

Returns true while the right mouse button is physically held down and Sober is focused.

if input.Mouse2Down() then print("RMB held") end

input.Mouse3Down() -> boolean

Returns true while the middle mouse button is physically held down and Sober is focused.

if input.Mouse3Down() then print("MMB held") end

input.Mouse1Pressed() -> boolean

Returns true once for the frame the left mouse button transitioned to pressed, consuming the edge.

if input.Mouse1Pressed() then print("LMB clicked") end

input.Mouse2Pressed() -> boolean

Returns true once for the frame the right mouse button transitioned to pressed, consuming the edge.

if input.Mouse2Pressed() then print("RMB clicked") end

input.Mouse3Pressed() -> boolean

Returns true once for the frame the middle mouse button transitioned to pressed, consuming the edge.

if input.Mouse3Pressed() then print("MMB clicked") end

input.Mouse1Released() -> boolean

Returns true once for the frame the left mouse button transitioned to released, consuming the edge.

if input.Mouse1Released() then print("LMB released") end

input.Mouse2Released() -> boolean

Returns true once for the frame the right mouse button transitioned to released, consuming the edge.

if input.Mouse2Released() then print("RMB released") end

input.Mouse3Released() -> boolean

Returns true once for the frame the middle mouse button transitioned to released, consuming the edge.

if input.Mouse3Released() then print("MMB released") end

input.IsRobloxActive() -> boolean

Polls input and returns true if Sober is currently the focused window.

if input.IsRobloxActive() then input.KeyPress("w") end

input.IsKeyPressed(key: string|number) -> boolean

Returns true if the given key (key name string or raw Linux keycode) is currently held down and Sober is focused.

if input.IsKeyPressed("w") then print("W held") end

input.IsKeyJustPressed(key: string|number) -> boolean

Returns true once per physical key press, consuming the edge, use for toggles rather than held state.

if input.IsKeyJustPressed("e") then print("toggled") end

input.IsMouse1Pressed() -> boolean

Returns true while the left mouse button is currently held down and Sober is focused.

if input.IsMouse1Pressed() then print("LMB down") end

input.IsMouse2Pressed() -> boolean

Returns true while the right mouse button is currently held down and Sober is focused.

if input.IsMouse2Pressed() then print("RMB down") end

input.KeyPress(key: string|number)

Sends a synthetic key-down event for the given key via the virtual input device.

input.KeyPress("space")

input.KeyRelease(key: string|number)

Sends a synthetic key-up event for the given key via the virtual input device.

input.KeyRelease("space")

keyboard.IsPressed(key: string|number): boolean

Returns whether the given key is currently held down, false if Sober is not focused.

if keyboard.IsPressed("space") then print("jumping") end

keyboard.Press(key: string|number, holdMs: number?)

Synthetically presses a key down, optionally auto-releasing it after holdMs milliseconds (capped at 5000).

keyboard.Press("w")
keyboard.Press("e", 200)

keyboard.Release(key: string|number)

Synthetically releases a key that is currently held down.

keyboard.Release("w")

keyboard.Click(key: string|number, holdMs: number?)

Presses and releases a key, holding for holdMs milliseconds (default 15, capped at 5000).

keyboard.Click("f")

input.Mouse1Press()

Sends a synthetic left mouse button down event.

input.Mouse1Press()

input.Mouse1Release()

Sends a synthetic left mouse button up event.

input.Mouse1Release()

input.Mouse1Click()

Sends a synthetic left mouse click, press followed by a short delay then release.

input.Mouse1Click()

input.Mouse2Press()

Sends a synthetic right mouse button down event.

input.Mouse2Press()

input.Mouse2Release()

Sends a synthetic right mouse button up event.

input.Mouse2Release()

input.Mouse2Click()

Sends a synthetic right mouse click, press followed by a short delay then release.

input.Mouse2Click()

input.MouseScroll(amount: number)

Sends a synthetic mouse wheel scroll event of the given amount.

input.MouseScroll(-1)

input.MouseMoveRel(dx: number, dy: number)

Sends a synthetic relative mouse movement of the given device pixel delta.

input.MouseMoveRel(10, 0)

input.MouseMoveAbs(x: number, y: number) -> nil

Moves the mouse toward an absolute screen position by computing and sending a relative delta from the engine’s current cursor location, may need repeat calls to converge under pointer acceleration.

input.MouseMoveAbs(500, 300)

mouse.IsClicked(button: number) -> boolean

Returns true if the given mouse button is currently held down and Roblox is focused.

if mouse.IsClicked(1) then print("left button held") end

mouse.Press(button: number) -> ()

Synthesizes a button-down event for the given mouse button.

mouse.Press(1)

mouse.Release(button: number) -> ()

Synthesizes a button-up event for the given mouse button.

mouse.Release(1)

mouse.Click(button: number, holdMs: number?) -> ()

Presses and releases the given mouse button, holding for an optional duration in milliseconds (default 15ms, clamped to 5000ms).

mouse.Click(1, 50)

mouse.Scroll(amount: number) -> ()

Emits a relative mouse wheel scroll event of the given amount.

mouse.Scroll(-1)

input.SetRobloxInput(enabled: boolean)

Enables or disables whether synthetic key/mouse press events are sent to Sober, releases always still go through.

input.SetRobloxInput(false)