Keybinds

Register persistent key bindings that players can rebind in the GTA V settings menu.

KOJA.registerKeyBind

local bind = KOJA.registerKeyBind(data)

Also available as an export:

local bind = exports['koja-lib']:registerKeyBind(data)

Parameters

Field
Type
Required
Description

name

string

Yes

Internal unique name (used as command name)

description

string

Yes

Description shown in the keybind menu

key

string

Yes

Default key (e.g. "E", "F5", "SPACE")

onPress

function

No

Called when the key is pressed

onRelease

function

No

Called when the key is released

Returns bind — a keybind object.

Keybind Object

Property / Method
Description

bind.key

The currently assigned key (reflects player rebinds)

bind:isPressed()

Returns true while the key is held

bind:disable(state)

Pass true to disable, false to re-enable

Examples

Simple press action

Press and release (toggle flashlight)

Check if pressed in a loop

Temporarily disable

Notes

  • Binds are automatically registered with RegisterKeyMapping so players can rebind them in Settings → Key Bindings → FiveM.

  • The bind is hidden from the chat suggestion list automatically.

  • Binds do not fire while the pause menu is open.

Last updated