DirkScripts
Docs
addKeybind
βΉοΈ Client Module - FiveM only
#lib.addKeybind
Register a keybinding that players can rebind via FiveM's settings.
lualocal 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
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | Unique keybind identifier |
description | string | yes | Label shown in FiveM keybind settings |
defaultMapper | string | no | Input mapper (default "keyboard") |
defaultKey | string | yes | Default key binding |
secondaryMapper | string | no | Secondary input mapper |
secondaryKey | string | no | Secondary default key |
disabled | boolean | no | Start disabled |
onPressed | function(self) | no | Called on key down |
onReleased | function(self, duration) | no | Called on key up, with hold duration in ms |
#Keybind Methods
luakeybind: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
