Difference between revisions of "ScriptHook: Key Binds"

From Nomad DB
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
A [[WD2 ScriptHook: Script|Script]] can register Key bindings.
+
A [[ScriptHook: Script|Script]] can register Key bindings.
  
 
==Registering a Key Bind==
 
==Registering a Key Bind==
To register a Key bind, use the [[WD2 ScriptHook: Script|Script]]'s [[WD2 ScriptHook: manifest.json|manifest.json]].
+
To register a Key bind, use the [[ScriptHook: Script|Script]]'s [[ScriptHook: manifest.json|manifest.json]].
  
 
'''manifest.json'''
 
'''manifest.json'''
Line 27: Line 27:
 
==Related Pages==
 
==Related Pages==
  
*[[WD2 ScriptHook]]
+
*[[ScriptHook]]
*[[WD2 ScriptHook: manifest.json]]
+
*[[ScriptHook: Script|manifest.json]]
 
*[[Key Codes]]
 
*[[Key Codes]]
  
[[Category:WD2 ScriptHook]]
+
[[Category:ScriptHook]]

Latest revision as of 12:29, 6 October 2020

A Script can register Key bindings.

Registering a Key Bind

To register a Key bind, use the Script's manifest.json.

manifest.json

"keyBinds": {
	"test": "F5"
}

List of Key Codes

Key Handler

Use ScriptHook.RegisterKeyHandler function.

Example

Registers a callback function to a Key binding. In combination with the manifest.json above, this code would print "Key Bind" to the Console when pressing F5.

ScriptHook.RegisterKeyHandler("test", function()
	print("Key Bind")
end)

Related Pages