-
Simple: Just add the
import.lua
file to your resources, and you're ready to start scripting! -
Easy: No need to tinker with
RegisterCommand
,RegisterKeyMapping
, or manual loops likeIsControlJustPressed
. -
Fast: Performance is optimized and handled seamlessly by the game engine.
-
Customizable: Tailor the controls to suit your preferences.
-
Download the latest release from GitHub.
-
Extract the contents of the zip file into your
resources
folder. -
Update your Sumneko LLS settings by adding the
meta.lua
file path to theworkspace.library
configuration. -
Include
ensure better-controls-fivem
in yourserver.cfg
file. -
Add
@better-controls-fivem/import.lua
to thefxmanifest.lua
file of any resource you want to use it in, and start scripting!
-- Triggered when the key is pressed
Controls:OnPress('F1', function(resp)
print('Press', json.encode(resp))
end)
-- Triggered when the key is pressed with additional modifiers
Controls:OnPress('F1', function(resp)
print('Press', json.encode(resp))
end, {
-- Available options:
-- ctrlKey = true, -- Trigger only if the Ctrl key is pressed
-- altKey = true, -- Trigger only if the Alt key is pressed
shiftKey = true -- Trigger only if the Shift key is pressed
})
-- Triggered while the key is held down
Controls:OnHold('F1', function(resp)
print('Hold', json.encode(resp))
end)
-- Triggered when the key is released
Controls:OnRelease('F1', function(resp)
print('Release', json.encode(resp))
end)