Event
sandbox:key_input
ClientFired when a keyboard key or mouse button is pressed or released
Signal
"sandbox:key_input"Arguments
| Type | Name | Description |
|---|---|---|
util.input.key | keycode | Key or mouse button identifier |
bool | pressed | true if pressed, false if released |
Fires for both keyboard keys and mouse buttons.
- Key-repeat echoes are suppressed — only the initial press and release are reported.
- If the engine console intercepts a key on press, that key will not fire this signal.
- Refer to the
util.input.keyenum for keycode values.
Example
util.event.on("sandbox:key_input", function(keycode, pressed)
if keycode == util.input.key.SPACE and pressed then
core.engine.print("info", "Space pressed")
end
end)util.event.on("sandbox:key_input", function(keycode, pressed)
if keycode == util.input.key.MOUSE_LEFT then
core.engine.print("info", "LMB " .. (pressed and "down" or "up"))
end
end)