Remapping keys Error: Invalid set index 'scancode'

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ingo_nikot
:warning: Old Version Published before Godot 3 was released.

EDIT:
I solved my problem, the error message was missleading

hello,

i have build a system were all key short cuts are listed. after the player changes some short cuts he can press save and InputMap should rebuild. but there is one part i could not accomplish yet, the (re)adding of the keys:

#...code to clean up InputMap etc
var event = InputEvent()
event.type = InputEvent.KEY
event.scancode = new_key #error here
InputMap.action_add_event(action, event )

I saw examples were “InputEvent” had the attribute “scancode” but i gues this changed. I did try “InputEventKey()” instead of “InputEvent()” because i found it in the docs and thought it an inherited type that could work (it hat the attribute “scancode” but it says it does not know “InputEventKey” at all.

so how can i add a specific key to an action?