From a4a23316844896d773bbf357d9d52b40cff207b7 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 20 Jun 2023 22:21:43 -0400 Subject: [PATCH] Allow unsetting hotkey with Escape Closes #244 --- src/hotkeys.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/hotkeys.py b/src/hotkeys.py index b0575467..08341be5 100644 --- a/src/hotkeys.py +++ b/src/hotkeys.py @@ -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)