Skip to content

Instantly share code, notes, and snippets.

@ijoschek
Last active December 22, 2018 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ijoschek/77d1118d0a3625fb1aaddead43e45e12 to your computer and use it in GitHub Desktop.
Save ijoschek/77d1118d0a3625fb1aaddead43e45e12 to your computer and use it in GitHub Desktop.
godot_custom_keybind_tut
func _change_key(new_key):
#Delete key of pressed button
if !InputMap.get_action_list(action_string).empty():
InputMap.action_erase_event(action_string, InputMap.get_action_list(action_string)[0])
#Check if new key was assigned somewhere
for i in ACTIONS:
if InputMap.action_has_event(i, new_key):
InputMap.action_erase_event(i, new_key)
#Add new Key
InputMap.action_add_event(action_string, new_key)
_set_keys()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment