Redefine my game keyboard

Godot Version

Question

I want to create a keyboard configuration for my game, but I can’t get the keyboard mapping to work correctly.

This is part of the lines of code of my script…

##Enun key selection dictionary
var dictionary_keyboard = {
	"Up": KEY_UP, 
	"Down": KEY_DOWN,
	"Left": KEY_LEFT,
	"Right": KEY_RIGHT,
	"Spc": KEY_SPACE,
	"Q": KEY_Q,
	"W": KEY_W,
	"M": KEY_M,
	"N": KEY_N,
	"S": KEY_S,
	"A": KEY_A,
	"D": KEY_D,
	"F": KEY_F,
	"E": KEY_E,
	"R": KEY_R,
	"Z": KEY_Z,
	"X": KEY_X,
	"C": KEY_C,     
}

func chage_key(boton: Button, event: InputEvent):
	timer_wait.start()
	boton.text = event.as_text()
	var enum_key = null
	#Scroll through the dictionary looking for the key corresponding to the last key used.
	for clave in dictionary_keyboard:
		if clave == button_key:
			#Get the corresponding enum key from the dictionary.
			enum_key  = dictionary_keyboard.get(clave)
			print("", enum_key)
			break
	#Creation of a new event input
	var input_event = InputEventKey.new()
	input_event.physical_keycode = enum_key
	#Delete the event action belonging to that key.
	InputMap.action_erase_event(select_key, input_event)
	#Add new event action of the key.
	InputMap.action_add_event(select_key, event)
	select_key = ""

What I intend with this code is to delete the previous assigned key and replace it with the new key that I assign. The problem is that the list returns a constant number and not the corresponding enum.

Ejemplo me devuelve:
KEY_UP = 4194320

I cannot delete the next key and several keys with the same function are assigned. Any solution that can help me, thank you very much.