mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 13:28:33 +00:00
Clone
5
LUA Keybinds
Robert Beekman edited this page 2017-09-12 14:20:21 +02:00
The Keybind module allows you to execute pieces of script when a certain key or mousebutton is pressed.
Overview
Functions
SetKeybind
Creates a keybind using the given variables.
Syntax:
SetKeybind(string name, string hotkey, PressType pressType function function, [params])
Required arguments
- name: A name to identify the keybind by
- hotkey: A hotkey to bind the keybind to such as "SHIFT+D"
- pressType: When to trigger, on press up or press down ("Up" or "Down")
- function: A LUA function to be called each time the keybind is pressed
Optional arguments
Note: The arguments between [brackets] are optional and you can leave them out.
- params: Paramaters you wish to pass to the function the timer will call on each keypress
Example:
-- Simply call a method
function kbTest()
print("oohai!")
end
Keybind.SetKeybind("test1", "SHIFT+D", kbTest)
-- Call a method with argument(s)
function kbTest2(message)
print(message)
end
Keybind.SetKeybind("test2", "SHIFT+F", kbTest2, "hello!!!")
RemoveKeybind
Removes an existing keybind.
RemoveKeybind(string name)
Required arguments
- name: The name of the keybind to remove
Example:
function kbTest()
-- As a test, remove the keybind after being pressed once
Keybind.RemoveKeybind("test")
end
Keybind.SetKeybind("test", "SHIFT+F", kbTest)