Keybind
Keybinds attach keyboard shortcuts to toggles or labels for quick actions.
Playground
Example Toggle
F
Leave blank to use the default modes list.
Keep toggle value in sync
Do not show in keybind list
Usage
You can create a Keybind by calling the AddKeyPicker method on a toggle or label reference.
Keybinds can hang off any element that returns a reference (for example AddToggle or AddLabel).
Arguments
local Toggle = Groupbox:AddToggle("MyToggle", {
Text = "Example Toggle",
Default = false,
})
local Keybind = Toggle:AddKeyPicker("MyKeybind", {
Text = "Example Keybind",
Default = "F",
Mode = "Toggle",
})| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Index/ID of the keybind | string | nil |
| 2 | Keybind configuration table | table | nil |
Configuration Table
Prop
Type
Methods
You can use the following methods to interact with the keybind:
SetValue
Sets the key and mode.
Keybind:SetValue({ "F", "Toggle" })| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Table containing { key, mode, modifiers? } | table | nil |
GetState
Returns whether the keybind is active.
local state = Keybind:GetState()| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | No arguments | – | – |
SetText
Updates the keybind's text.
Keybind:SetText(text)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | New keybind text | string | nil |
Update
Refreshes the keybind display.
Keybind:Update()| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | No arguments | – | – |
OnClick
Sets the click callback.
Keybind:OnClick(function)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Callback executed on click | function | nil |
OnChanged
Sets the change callback.
Keybind:OnChanged(function)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Callback executed when the keybind changes | function | nil |
Example
local Options = Library.Options
local Toggle = Groupbox:AddToggle("AutoFarm", {
Text = "Enable Auto Farm",
Default = false,
})
local Keybind = Toggle:AddKeyPicker("AutoFarmKey", {
Default = "F",
Text = "Auto Farm Key",
Mode = "Toggle",
})
Options.AutoFarmKey:OnClick(function()
print("Keybind clicked:", Options.AutoFarmKey:GetState())
end)
Options.AutoFarmKey:OnChanged(function()
print("Key changed to:", table.unpack(Options.AutoFarmKey.Modifiers or {}), Options.AutoFarmKey.Value)
end)