Native for secondary key bindings

Ever since we got the new key mappings, I am waiting for the possibility to add a secondary binding via code.
As far as I know, there is currently no way to do this, unless the command that appears in the fivem.cfg (e.g. rbind TestResource PAD_DIGITALBUTTON LUP "~!+inventory") can just be used via code and is still persistent and doesn’t fiddle with the background logic.

I am suggesting that a native function gets implemented to do this instead.

Example

RegisterCommand("+vehiclelock", function()
    -- do something
end, false)
RegisterCommand("-vehiclelock", function()
    -- do something else
end, false)

RegisterKeyMapping("+vehiclelock", "(Un)lock vehicle", "keyboard", "X")

-- new native:
AddSecondaryKeyMapping("+vehiclelock", "PAD_DIGITALBUTTON", "LUP")

Potential use case

Mainly converting scripts using the “control” natives for both keyboard and controller input. If people want their server compatible for both keyboard and controller players, they would need to tell their controller players “You need to set your controller binds manually”.
And the alternative would be to still have a loop checking for controller input as well. Which is not really what RegisterKeyMapping was made for in the first place.

1 Like

You can already do this with the regular key map

2 Likes