sandbox:key_input
Client
Fired when a keyboard key or mouse button is pressed or released
Signal
"sandbox:key_input"Arguments
| Type | Name | Description |
|---|---|---|
int | keycode | Godot Key or MouseButton enum value identifying the key or button |
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 Godot's
KeyandMouseButtonenums viautil.inputfor 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.mouse_button.LEFT then
core.engine.print("info", "LMB " .. (pressed and "down" or "up"))
end
end)