Skip to content

Keybind stops working after remapping to same key during active press #3793

@Grainbox

Description

@Grainbox

What happened?

Remapping a keybind to the same key while holding it down causes the keybind to permanently stop responding. This affects resources using RegisterKeyMapping with command pairs (+command / -command) like pma-voice radio talk.

When a player presses a keybind at the exact moment of remapping it to the same key, the keybind completely stops responding. The -command is never called, variables remain stuck at true, and both physical key presses and ExecuteCommand() calls are completely ignored. The keybind becomes entirely dead.

Expected result

The keybind should continue working after remapping, or at minimum there should be a Lua API to reset the key state. Players shouldn't need to restart the entire FiveM client to recover from this.

Reproduction steps

  1. Join server with a working keybind (e.g., LEFT ALT for radio talk)
  2. Open: ESC → Settings → Keybinds → FiveM
  3. Find the keybind and click to remap it
  4. Press the SAME KEY to remap (LEFT ALT → LEFT ALT)
    • At this exact moment, the +command triggers before the remapping completes
  5. Try pressing the key again → Nothing happens, keybind is completely dead
-- fxmanifest.lua
fx_version 'cerulean'
game 'gta5'
client_script 'test.lua'

-- test.lua
local isPressed = false

RegisterCommand('+testkey', function()
    isPressed = true
    print("Key pressed")
end, false)

RegisterCommand('-testkey', function()
    isPressed = false
    print("Key released")
end, false)

RegisterKeyMapping('+testkey', 'Test Key', 'keyboard', 'F9')

RegisterCommand('checkstate', function()
    print("isPressed =", isPressed)
end, false)

Importancy

There's a workaround

Area(s)

FiveM

Specific version(s)

(b3095) (Canary)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtriageNeeds a preliminary assessment to determine the urgency and required action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions