sandbox:key_input

Client

Fired when a keyboard key or mouse button is pressed or released


Signal

"sandbox:key_input"

Arguments

TypeNameDescription
intkeycodeGodot Key or MouseButton enum value identifying the key or button
boolpressedtrue 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 Key and MouseButton enums via util.input for keycode values.

Example

Detect spacebar press
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)
Detect left mouse button
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)

On this page