ScriptHook.RegisterKeyHandler
From Nomad DB
Revision as of 13:30, 15 April 2020 by Jan (talk | contribs) (Created page with "Registers a Lua callback to a Key Bind. The Key Bind has to be registered inside manifest.json first. == Synta...")
Registers a Lua callback to a Key Bind. The Key Bind has to be registered inside manifest.json first.
Syntax
ScriptHook.RegisterKeyHandler(name, callback)
- name (string) Key bind name, must match manifest.json entry
- callback (function) Lua callback
Example
The example below shows you how to a bind a custom Simple Menu toggle to a key handler. manifest.json (excerpt)
"keyBinds": {
"menu": "F5"
}
Code
local my_menu = UI.SimpleMenu()
-- ~~ menu code ~~ --
ScriptHook.RegisterKeyHandler("menu", function()
my_menu:Toggle()
end)