diff --git a/LUA-Keybinds.md b/LUA-Keybinds.md new file mode 100644 index 0000000..05bfbae --- /dev/null +++ b/LUA-Keybinds.md @@ -0,0 +1,55 @@ +The Keybind module allows you to execute pieces of script when a certain key or mousebutton is pressed. + +## Overview +* [SetKeybind](https://github.com/SpoinkyNL/Artemis/wiki/luakeybinds#setkeybind) +* [RemoveKeybind](https://github.com/SpoinkyNL/Artemis/wiki/luakeybinds#removekeybind) + +## Functions +### SetKeybind +Creates a keybind using the given variables. +#### Syntax: +```lua +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: +```lua +-- 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. +```lua +RemoveKeybind(string name); +``` +##### Required arguments +- **name:** The name of the keybind to remove + +#### Example: +```lua +function kbTest() + -- As a test, remove the keybind after being pressed once + Keybind.RemoveKeybind("test"); +end +Keybind.SetKeybind("test", "SHIFT+F", kbTest); +``` +--- \ No newline at end of file