Skip to content

Commit

Permalink
Allow unsetting hotkey with Escape
Browse files Browse the repository at this point in the history
Closes #244
  • Loading branch information
Avasam committed Jun 23, 2023
1 parent 5b02752 commit a4a2331
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/hotkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,22 @@ def read_and_set_hotkey():
try:
hotkey_name = preselected_hotkey_name if preselected_hotkey_name else __read_hotkey()

# Unset hotkey by pressing "Escape". This is the same behaviour as LiveSplit
if hotkey_name == "esc":
_unhook(getattr(autosplit, f"{hotkey}_hotkey"))
autosplit.settings_dict[f"{hotkey}_hotkey"] = "" # pyright: ignore[reportGeneralTypeIssues]
if autosplit.SettingsWidget:
getattr(autosplit.SettingsWidget, f"{hotkey}_input").setText("")
return

if not is_valid_hotkey_name(hotkey_name):
autosplit.show_error_signal.emit(lambda: error_messages.invalid_hotkey(hotkey_name))
return

# Try to remove the previously set hotkey if there is one
_unhook(getattr(autosplit, f"{hotkey}_hotkey"))
# Remove any hotkey using the same key combination

# Remove any hotkey using the same key combination
__remove_key_already_set(autosplit, hotkey_name)

action = __get_hotkey_action(autosplit, hotkey)
Expand Down

0 comments on commit a4a2331

Please sign in to comment.