From 72286ebb8bbe5f764f29675104b72d4cbbb22465 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Thu, 24 Sep 2026 11:38:38 -0700 Subject: [PATCH] ImGui: a bare modifier key does not end the C-k prefix After C-k, pressing Shift (for C-k C, C-k ^ or a shifted symbol), or pressing Ctrl again for C-k C-d, reached the k-prefix handler as a key with no ASCII value, which reported an unknown command and left the prefix; the suffix was then inserted as text. Modifier keys pressed on their own are now ignored while the prefix waits. Co-Authored-By: Claude Opus 5.5 (1M context) --- ImGuiInputHandler.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ImGuiInputHandler.cc b/ImGuiInputHandler.cc index 31d748c..9119647 100644 --- a/ImGuiInputHandler.cc +++ b/ImGuiInputHandler.cc @@ -157,6 +157,24 @@ map_key(const SDL_Keycode key, // If we are in k-prefix, interpret the very next key via the C-k keymap immediately. if (k_prefix) { + // A modifier pressed on its own (Shift for C-k C or C-k ^, Ctrl + // pressed again for C-k C-d) is not the suffix: keep waiting. + switch (key) { + case SDLK_LSHIFT: + case SDLK_RSHIFT: + case SDLK_LCTRL: + case SDLK_RCTRL: + case SDLK_LALT: + case SDLK_RALT: + case SDLK_LGUI: + case SDLK_RGUI: + case SDLK_CAPSLOCK: + case SDLK_MODE: + out.hasCommand = false; + return true; + default: + break; + } esc_meta = false; // Normalize to ASCII; preserve case for letters using Shift int ascii_key = 0;