Input
Simulate mouse and keyboard input in the Roblox window.
Use these functions to move the mouse, send key presses and control input to the Roblox window.
Window and cursor state
iswindowactive
iswindowactive(): booleaniswindowactive returns whether the Roblox window is currently active.
Also available as isrbxactive and isgameactive.
Returns
booleanWhether Roblox is active.
setwindowtitle
setwindowtitle(title: string): ()setwindowtitle changes the Roblox window title.
Parameters
titlestring- UTF-8 window title. An empty string is allowed.
Returns
()No return values.
Example
getwindowtitle
getwindowtitle(): stringgetwindowtitle reads the current Roblox window title.
Returns
stringCurrent title encoded as UTF-8.
Example
setwindowicon
setwindowicon(path: string? = nil): ()setwindowicon changes both Roblox window icons using a workspace .ico file, or restores the original icons.
Parameters
pathstring?- Optional.Workspace-relative path to an existing
.icofile; omit or pass nil to restore the original icons. Defaultnil.
Returns
()No return values.
Example
getmousestate
getmousestate(): booleangetmousestate returns whether the Lynx mouse cursor is visible.
Returns
booleanWhether the Lynx mouse cursor is visible.
setmousestate
setmousestate(enabled: boolean): ()setmousestate shows or hides the Lynx mouse cursor.
Parameters
enabledboolean- Whether to enable this setting.
Returns
()This function does not return a value.
Keyboard
Output key functions accept a Windows virtual-key integer from 1 through 255 or a supported Enum.KeyCode. State queries accept only the numeric virtual-key form. Unsupported enum mappings and invalid codes raise an argument error.
keypress
keypress(key: number | Enum.KeyCode): ()keypress presses the specified key without releasing it.
Parameters
keynumber | Enum.KeyCode- The key to press, release or inspect.
Returns
()This function does not return a value.
keyrelease
keyrelease(key: number | Enum.KeyCode): ()keyrelease releases the specified key.
Parameters
keynumber | Enum.KeyCode- The key to press, release or inspect.
Returns
()This function does not return a value.
keyclick
keyclick(key: number | Enum.KeyCode): ()keyclick presses and releases the specified key.
Also available as keytap.
Parameters
keynumber | Enum.KeyCode- The key to press, release or inspect.
Returns
()This function does not return a value.
iskeydown
iskeydown(key: number): booleaniskeydown returns whether the specified key is held down.
Parameters
keynumber- The key to press, release or inspect.
Returns
booleanWhether the key is currently pressed.
iskeytoggled
iskeytoggled(key: number): booleaniskeytoggled returns whether the specified toggle key is enabled.
Parameters
keynumber- The key to press, release or inspect.
Returns
booleanWhether the toggle key is enabled.
Mouse buttons
Button and scroll events are sent only while the Roblox window is active.
mouse1click
mouse1click(): ()mouse1click presses and releases the left mouse button.
Returns
()This function does not return a value.
mouse2click
mouse2click(): ()mouse2click presses and releases the right mouse button.
Returns
()This function does not return a value.
mouse1press
mouse1press([x: number, y: number]): ()mouse1press presses the left mouse button.
Parameters
xnumber?- Optional.The horizontal position in Roblox client coordinates.
ynumber?- Optional.The vertical position in Roblox client coordinates.
Returns
()This function does not return a value.
mouse1release
mouse1release([x: number, y: number]): ()mouse1release releases the left mouse button.
Parameters
xnumber?- Optional.The horizontal position in Roblox client coordinates.
ynumber?- Optional.The vertical position in Roblox client coordinates.
Returns
()This function does not return a value.
mouse2press
mouse2press([x: number, y: number]): ()mouse2press presses the right mouse button.
Parameters
xnumber?- Optional.The horizontal position in Roblox client coordinates.
ynumber?- Optional.The vertical position in Roblox client coordinates.
Returns
()This function does not return a value.
mouse2release
mouse2release([x: number, y: number]): ()mouse2release releases the right mouse button.
Parameters
xnumber?- Optional.The horizontal position in Roblox client coordinates.
ynumber?- Optional.The vertical position in Roblox client coordinates.
Returns
()This function does not return a value.
Mouse movement
mousemoveabs
mousemoveabs(x: number, y: number, internal: any?): ()mousemoveabs moves the mouse to a position within the Roblox window.
Parameters
xnumber- The horizontal position in Roblox client coordinates.
ynumber- The vertical position in Roblox client coordinates.
internalany?- Optional.When supplied and not nil, a truthy value selects cursor-only movement and false selects desktop movement. Omit or pass nil for automatic selection.
Returns
()This function does not return a value.
mousemoverel
mousemoverel(dx: number, dy: number, internal: any?): ()mousemoverel moves the mouse by the specified horizontal and vertical distances.
Parameters
dxnumber- The horizontal distance in pixels.
dynumber- The vertical distance in pixels.
internalany?- Optional.When supplied and not nil, a truthy value selects cursor-only movement and false selects desktop movement. Omit or pass nil for automatic selection.
Returns
()This function does not return a value.
mousescroll
mousescroll(delta: number | boolean, [x: number, y: number]): ()mousescroll scrolls the mouse wheel.
Parameters
deltanumber | boolean- The wheel distance, or true for one forward step and false for one backward step.
xnumber?- Optional.The horizontal position in Roblox client coordinates.
ynumber?- Optional.The vertical position in Roblox client coordinates.
Returns
()This function does not return a value.
Written for Lynx 0.747
Something unclear? Tell us on Discord