Docs/Library/Modules/addKeybind

addKeybind

Library
Updated 2 months ago · v1.3.7
i

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
Was this page helpful?
This page was last updated on 12 March 2026
DIRKSCRIPTS
All you need for your FiveM server.10% off your first order

Unsubscribe any time.

Copyright © 2026 DirkScripts. Not affiliated with or endorsed by Rockstar North or Take-Two Interactive.