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.
Read state
Section titled “Read state”input.Available
Section titled “input.Available”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") endinput.Poll
Section titled “input.Poll”input.Poll()
Polls all discovered evdev devices once, updating held-key state and press/release edges.
input.Poll()input.Mouse1Down
Section titled “input.Mouse1Down”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") endinput.Mouse2Down
Section titled “input.Mouse2Down”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") endinput.Mouse3Down
Section titled “input.Mouse3Down”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") endinput.Mouse1Pressed
Section titled “input.Mouse1Pressed”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") endinput.Mouse2Pressed
Section titled “input.Mouse2Pressed”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") endinput.Mouse3Pressed
Section titled “input.Mouse3Pressed”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") endinput.Mouse1Released
Section titled “input.Mouse1Released”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") endinput.Mouse2Released
Section titled “input.Mouse2Released”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") endinput.Mouse3Released
Section titled “input.Mouse3Released”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") endinput.IsRobloxActive
Section titled “input.IsRobloxActive”input.IsRobloxActive() -> boolean
Polls input and returns true if Sober is currently the focused window.
if input.IsRobloxActive() then input.KeyPress("w") endinput.IsKeyPressed
Section titled “input.IsKeyPressed”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") endinput.IsKeyJustPressed
Section titled “input.IsKeyJustPressed”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") endinput.IsMouse1Pressed
Section titled “input.IsMouse1Pressed”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") endinput.IsMouse2Pressed
Section titled “input.IsMouse2Pressed”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") endKeyboard output
Section titled “Keyboard output”input.KeyPress
Section titled “input.KeyPress”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
Section titled “input.KeyRelease”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
Section titled “keyboard.IsPressed”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") endkeyboard.Press
Section titled “keyboard.Press”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
Section titled “keyboard.Release”keyboard.Release(key: string|number)
Synthetically releases a key that is currently held down.
keyboard.Release("w")keyboard.Click
Section titled “keyboard.Click”keyboard.Click(key: string|number, holdMs: number?)
Presses and releases a key, holding for holdMs milliseconds (default 15, capped at 5000).
keyboard.Click("f")Mouse output
Section titled “Mouse output”input.Mouse1Press
Section titled “input.Mouse1Press”input.Mouse1Press()
Sends a synthetic left mouse button down event.
input.Mouse1Press()input.Mouse1Release
Section titled “input.Mouse1Release”input.Mouse1Release()
Sends a synthetic left mouse button up event.
input.Mouse1Release()input.Mouse1Click
Section titled “input.Mouse1Click”input.Mouse1Click()
Sends a synthetic left mouse click, press followed by a short delay then release.
input.Mouse1Click()input.Mouse2Press
Section titled “input.Mouse2Press”input.Mouse2Press()
Sends a synthetic right mouse button down event.
input.Mouse2Press()input.Mouse2Release
Section titled “input.Mouse2Release”input.Mouse2Release()
Sends a synthetic right mouse button up event.
input.Mouse2Release()input.Mouse2Click
Section titled “input.Mouse2Click”input.Mouse2Click()
Sends a synthetic right mouse click, press followed by a short delay then release.
input.Mouse2Click()input.MouseScroll
Section titled “input.MouseScroll”input.MouseScroll(amount: number)
Sends a synthetic mouse wheel scroll event of the given amount.
input.MouseScroll(-1)input.MouseMoveRel
Section titled “input.MouseMoveRel”input.MouseMoveRel(dx: number, dy: number)
Sends a synthetic relative mouse movement of the given device pixel delta.
input.MouseMoveRel(10, 0)input.MouseMoveAbs
Section titled “input.MouseMoveAbs”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
Section titled “mouse.IsClicked”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") endmouse.Press
Section titled “mouse.Press”mouse.Press(button: number) -> ()
Synthesizes a button-down event for the given mouse button.
mouse.Press(1)mouse.Release
Section titled “mouse.Release”mouse.Release(button: number) -> ()
Synthesizes a button-up event for the given mouse button.
mouse.Release(1)mouse.Click
Section titled “mouse.Click”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
Section titled “mouse.Scroll”mouse.Scroll(amount: number) -> ()
Emits a relative mouse wheel scroll event of the given amount.
mouse.Scroll(-1)input.SetRobloxInput
Section titled “input.SetRobloxInput”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)