Input

keypress

Sends a key down event when the Roblox window is active.

Syntax

keypress(keyCode: number)

Arguments

NameTypeDescription
keyCodenumberWindows virtual-key code read as a Lua number and converted to an integer before Windows key mapping is called.

Description

Sends a key down event when the Roblox window is active. The keyCode argument is checked as a Lua number, and sent with keyboard input with KEYEVENTF_SCANCODE. This function does not send a key up event. If isrbxactive would be false, the function returns without sending input.

Call it with 1 parameter(s): keyCode. The argument table explains which values are required and which ones only refine the behavior.

It does not return data. Treat the call as an action and handle errors around the call site when needed.

Example

Example call with placeholder values.

keypress(1)