ScriptsAboutBlogToolsKnowledge BaseReviewsFAQBasketDocsSupport
client

RegisterKeyMapping

FiveM client native documentation with a Lua example.

Summary

Binds a command to a key the player can rebind in FiveM settings. The correct, rebindable way to add keybinds instead of polling controls.

Returns

void

Parameters

commandNamestringThe command to run.
descriptionstringShown in the key bindings menu.
defaultMapperstringe.g. 'keyboard'.
defaultParameterstringDefault key, e.g. 'E'.

Example

RegisterCommand('openmenu', function() openMenu() end, false)
RegisterKeyMapping('openmenu', 'Open the menu', 'keyboard', 'F5')

Common pitfalls

  • Register a matching command for the mapping to trigger.
  • Players can rebind it in Settings > Key Bindings — the friendly, modern approach.
  • Avoid per-frame IsControlPressed polling when a keymapping fits.

Related natives

Related guides

FiveM scripts done right

Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.

Browse Scripts →