Not sure if this would work in your project, but the way I'd approach this would be to have a dictionary of key codes and their related actions
{"up": KEY_W, "down": KEY_S, etc.}
And then in your remap function you could have
func _input(event):
if event is InputEventKey and event.pressed:
keymap_dictionary[the_key_im_remapping] = event.scancode
It might change the way you need to get user input though.