feat: add generic modifier support via CSI u escape sequences#577
Open
menny wants to merge 1 commit into
Open
Conversation
Author
|
This is useful for me as some of the CLIs I use over ssh have special handling for SHIFT + ENTER. |
butlerx
approved these changes
Feb 18, 2026
Owner
|
Hey @menny - this PR has merge conflicts. Could you rebase it against main? The feature looks good. |
There was a problem hiding this comment.
Pull request overview
This PR adds client-side handling for modified “special keys” (Enter/Tab/Backspace/Escape) by converting them into CSI u escape sequences via attachCustomKeyEventHandler, aiming to improve interoperability with modern TUIs that rely on CSI u for modifier-aware input.
Changes:
- Added
modifierHandlerto map modified special keys to CSI u sequences and intercept those key events. - Updated terminal configuration to apply both copy shortcut handling and modifier mapping in the custom key event handler.
- Added unit tests for modifier mapping behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/client/wetty/term/confiruragtion.ts | Adds CSI u modifier mapping handler and wires it into xterm custom key handling. |
| src/client/wetty/term/confiruragtion.spec.ts | Adds unit tests for the modifier mapping logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+30
to
+33
| const code = specialKeys[e.key]; | ||
| const mod = modifiers + 1; // CSI u uses 1-based modifier mapping | ||
| // Send the CSI u sequence: ESC [ code ; mod u | ||
| window.wetty_term?.input(`\x1b[${code};${mod}u`, false); |
Comment on lines
+21
to
+27
| // Key codes for special keys we want to support generically | ||
| const specialKeys: Record<string, number> = { | ||
| Enter: 13, | ||
| Tab: 9, | ||
| Backspace: 127, | ||
| Escape: 27, | ||
| }; |
Comment on lines
+4
to
+18
| import { modifierHandler } from './confiruragtion'; | ||
|
|
||
| describe('modifierHandler', () => { | ||
| let inputStub: sinon.SinonStub; | ||
|
|
||
| beforeEach(() => { | ||
| inputStub = sinon.stub(); | ||
| (window as any).wetty_term = { | ||
| input: inputStub | ||
| }; | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| delete (window as any).wetty_term; | ||
| sinon.restore(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for modified special keys (Shift, Ctrl, Alt, Meta) by implementing the standard CSI u (Unicode keyboard input) protocol.
Specifically, it handles:
The implementation hooks into attachCustomKeyEventHandler to intercept raw keyboard events and map them to standard escape sequences (e.g. \x1b[13;2u for Shift+Enter).
Includes unit tests for the modifier mapping logic.