local Keybind = Tab:AddKeybind("Keybind", {
Title = "Keybind",
Description = "Keybind Description",
Mode = "Toggle", -- Always, Toggle, Hold
Default = "LeftControl", -- String as the name of the keybind (MB1, MB2 for mouse buttons)
-- Occurs when the keybind is clicked, Value is `true`/`false`
Callback = function(Value)
print("Keybind clicked!", Value)
end,
-- Occurs when the keybind itself is changed, `New` is a KeyCode Enum OR a UserInputType Enum
ChangedCallback = function(New)
print("Keybind changed!", New)
end
})
Event Handling
OnClick is only fired when you press the keybind and the mode is Toggle
Otherwise, you will have to use Keybind:GetState()
Keybind:OnClick(function()
print("Keybind clicked:", Keybind:GetState())
end)
Keybind:OnChanged(function()
print("Keybind changed:", Keybind.Value)
end)
task.spawn(function()
while true do
wait(1)
-- example for checking if a keybind is being pressed
local state = Keybind:GetState()
if state then
print("Keybind is being held down")
end
if Fluent.Unloaded then break end
end
end)
Changing Value
Keybind:SetValue("MB2", "Toggle") -- Sets keybind to MB2, mode to Hold