DirkScripts Logo

Login With FiveM

Login

πŸ“š Library
β€Ί
Modules
β€Ί

addKeybind

addKeybind

ℹ️ Client Module - FiveM only

lib.addKeybind

Register a keybinding that players can rebind via FiveM's settings.

lua
local keybind = lib.addKeybind({
    name = 'open_inventory',
    description = 'Open Inventory',
    defaultMapper = 'keyboard',
    defaultKey = 'TAB',
    onPressed = function(self)
        print('Key pressed')
    end,
    onReleased = function(self, duration)
        print('Key released after', duration, 'ms')
    end,
})

Options

FieldTypeRequiredDescription
namestringyesUnique keybind identifier
descriptionstringyesLabel shown in FiveM keybind settings
defaultMapperstringnoInput mapper (default "keyboard")
defaultKeystringyesDefault key binding
secondaryMapperstringnoSecondary input mapper
secondaryKeystringnoSecondary default key
disabledbooleannoStart disabled
onPressedfunction(self)noCalled on key down
onReleasedfunction(self, duration)noCalled on key up, with hold duration in ms

Keybind Methods

lua
keybind:disable(true)           -- disable the keybind
keybind:disable(false)          -- re-enable it
keybind:getCurrentKey()         -- get the player's current binding
keybind:isControlPressed()      -- check if currently held

Copyright Β© 2026 DirkScripts.

Not affiliated with or endorsed by Rockstar North, Take-Two Interactive, or any other rights holders. FiveM is a copyright and registered trademark of Take-Two Interactive Software, Inc.
Our checkout system is provided by Tebex Limited, who manage payment processing, product delivery, and billing support. Prices shown in currencies other than GBP are approximate conversions updated daily. All purchases are processed in GBP, so the final amount charged may vary depending on your bank or payment provider’s exchange rate.