bind¶
Registers a keybind - runs the callback whenever the key combo is pressed.
Combos are +-separated strings of key names,
case-insensitive.
You can also pass an options table:
block(boolean, defaulttrue): Iftrue, the key event won't reach the game. Setfalseif you want the game to see the press too.
Example¶
local tx = require("tuxinjector")
-- Switch to Thin mode on Ctrl+F1 (key is blocked from game)
tx.bind("ctrl+F1", function()
tx.switch_mode("Thin")
end)
-- Toggle GUI on F2 (key is also passed to game)
tx.bind("F2", function()
tx.toggle_gui()
end, { block = false })
-- Multi-key combo
tx.bind("ctrl+shift+Z", function()
tx.log("ctrl+shift+z pressed")
end)
Arguments¶
keys: stringcallback: functionoptions: table (optional)
Return values¶
None
This function can only be called during config-time (top-level execution). Calling it inside a keybind callback will have no effect until the next config reload.