How to add an InputEvent to InputMap with code?

:bust_in_silhouette: Reply From: Xrayez

Never used it but I think it’ll go like this:

func _ready():
    InputMap.add_action("my_action")
    InputMap.action_add_event("my_action", event)

See InputMap singleton documentation for other methods on how to modify input map.

Thank you. But what I confused in is how to set an InputEvent binding a key like “KEY_A” so that when I press the “A” key it can feedback the action Input.is_action_pressed("A").
Here is the Input singleton of the document:

var ev = InputEventAction.new()
ev.set_as_action("move_left", true)
Input.parse_input_event(ev)

Still not understand how to do it.

DogeMassaji | 2018-07-10 15:55

1 Like