How o use InputMap.action_erase_event()

Godot Version

Godot v4.4

Question

I’m trying to edit InputMap at runtime but I have no idea what it wants for the second argument and nothing I’ve seen has helped at all
That’s it

Perhaps you mixed up InputMap.action_erase_event() with InputMap.action_erase_events()

No, I want to erase a specific event - but what is the name of said event? For example, I tried this to remove the W key from one of the actions

await firstmotioninput()
if firstmotion:
	InputMap.action_erase_event("lynca1_jump",InputMap.action_get_events("lynca1_jump").InputEventKey.87)

As the docs say, event: InputEvent is an InputEvent. It would be hard to construct the InputEvent through code, so you should use InputMap.action_get_events, which returns an Array. You can access the event you want to remove with and index (number).

If you have multiple events for the action, you can check which event is the one you want to delete with code.

var events := InputMap.action_get_events("lyncal_jump")
for event in events:
    if event is InputEventKey and event.get_keycode_with_modifiers() == KEY_W:
        InputMap.action_erase_event("lyncal_jump", event)
        break
1 Like