💣
idontgiveaf's fluent gui
  • Fluent Library
    • Example Script
  • Fluent
    • Setup
      • Interface and Save Manager
      • Properties
  • Components
    • Window
      • Tabs
      • Dialog
  • elements
    • Guide
      • Destroying Elements
      • Section
      • Paragraphs
      • Buttons
      • Toggles
      • Sliders
      • Inputs
      • Dropdowns
      • Colorpickers
      • Keybinds
Powered by GitBook
On this page
  • Event Handling
  • Changing Value
  1. elements
  2. Guide

Keybinds

I do not want to put information on this.

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
PreviousColorpickers

Last updated 7 months ago