Skip to content

Hold IMGUI keyboard focus while the terminal is focused - #3205

Open
sparr wants to merge 1 commit into
KSP-KOS:developfrom
sparr:terminal-keyboard-focus
Open

sparr wants to merge 1 commit into
KSP-KOS:developfrom
sparr:terminal-keyboard-focus

Conversation

@sparr

@sparr sparr commented Oct 15, 2026

Copy link
Copy Markdown

The terminal currently implements "focus" and reads key events directly, so GUIUtility.keyboardControl stays 0 while typing in it. Mods that check keyboardControl or GUI.GetNameOfFocusedControl() before acting on hotkeys don't know kOS has pseudo-focus and so trigger their hotkeys while typing into the terminal. The file editor does not have this problem because its TextArea holds keyboard focus.

This PR registers a named keyboard control in the terminal window, take keyboard focus with it when the terminal locks, and releases it on unlock. Both happen during OnGUI, since setting keyboardControl from Update has no effect.

AI Disclosure This PR code and commit message were written by Claude Opus 5.5. I have reviewed the code and tested in-game, while also drafting Boris-Barboris/AtmosphereAutopilot#52 to fix the other side of the issue for a particular mod. I understand what the code is doing and think it's an appropriate minimal fix here.

The terminal reads key events itself rather than through a text field,
so GUIUtility.keyboardControl stayed 0 while typing in it. Mods that
check keyboardControl or GUI.GetNameOfFocusedControl() before acting on
hotkeys treated terminal keystrokes as hotkeys. The file editor did not
have this problem because its TextArea holds keyboard focus.

Register a named keyboard control in the terminal window, take keyboard
focus with it when the terminal locks, and release it on unlock. Both
happen during OnGUI, since setting keyboardControl from Update has no
effect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant