How do you use scancodes to make changes to key mappings

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By YuleTide

I have managed to use an event to allow a user to change keymappings as part of the menu. I have a saved config file and I want to make sure when the user logs in the changed key settings stay in place. To do this I have saved the scancodes of the keys selected as part of the event but I am having problems using the scancodes to change the key mappings the next time I log into the game.

Can anyone tell me how to either convert the scancode into a form that I can use to change the keymappings or else how to use the scancodes directly to do this?

As some context this is the code I have tried

scan_code = $"/root/GloVars".move_left
var new_k =
InputMap.action_add_event("move_left", scan_code)

but it fails with the error

Invalid type in function “action add event” in base inputmap. Cannot convert arguement 2 from int to object

YuleTide | 2022-07-09 21:25

:bust_in_silhouette: Reply From: Gluon

Try changing

InputMap.action_add_event("move_left", scan_code)


InputMap.action_add_event("move_left", new_k)

Oh thats embarrasing. Thank you it worked!

YuleTide | 2022-07-09 23:38