ScriptHook.RegisterKeyHandler

From Nomad DB

Registers a Lua callback to a Key Bind. The Key Bind has to be registered inside manifest.json first.

SimpleMenu

You can use UI.SimpleMenu to create custom Menus for your Script, which you can bind to a key handler. See UISimpleMenu:Toggle or the example below for more information.

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)

Related Pages