input
The state of keys and mouse buttons anywhere, while the game or the overlay menu has the focus.
These functions need the input permission: list it in the manifest and have the user grant it on the Scripts page. They report state only (is this key down right now); there is no history and no way to send keys. They return nothing useful while neither the game nor the menu has the focus. See input for virtual-key codes.
Reference#
input.key_down#permission: inputsince 1.0
input.key_down(vk: integer): booleanAsks whether a key or mouse button is down.
| Parameter | Type | Description |
|---|---|---|
vk | integer | A Windows virtual-key code, for example 0x46 for F or 0x01 for the left mouse button. |
| Returns | Description |
|---|---|
boolean | Whether the key or button is held. |
-- manifest: "permissions": ["input"]
local was = false
events.on("frame", function()
local down = input.key_down(0x46) -- F
if down and not was then log.info("F pressed") end
was = down
end)input.mouse#permission: inputsince 1.0
input.mouse(): number | nil, numberThe pointer position in overlay pixels.
| Returns | Description |
|---|---|
number | nil | Pointer x, or nil when it cannot be read. |
number | Pointer y. |