fix: let xterm.js handle keyboard input natively for scroll-on-input

Only intercept keys when mobile virtual modifier buttons are active.
Previously all special keys (Enter, Ctrl+C, arrows) were intercepted
and manually re-encoded, bypassing xterm's built-in scrollOnUserInput.
This commit is contained in:
Mohamed Boudra
2026-04-10 15:11:14 +07:00
parent 0f005172ce
commit 033c4bcbf2
2 changed files with 14 additions and 11 deletions
+13 -5
View File
@@ -52,7 +52,7 @@ describe("terminal key helpers", () => {
});
});
it("intercepts special keys and modifier combos", () => {
it("only intercepts when pending modifiers are active", () => {
expect(
shouldInterceptDomTerminalKey({
key: "Escape",
@@ -60,7 +60,7 @@ describe("terminal key helpers", () => {
altKey: false,
pendingModifiers: { ctrl: false, shift: false, alt: false },
}),
).toBe(true);
).toBe(false);
expect(
shouldInterceptDomTerminalKey({
key: "c",
@@ -68,15 +68,23 @@ describe("terminal key helpers", () => {
altKey: false,
pendingModifiers: { ctrl: false, shift: false, alt: false },
}),
).toBe(true);
).toBe(false);
expect(
shouldInterceptDomTerminalKey({
key: "c",
ctrlKey: false,
altKey: false,
pendingModifiers: { ctrl: false, shift: false, alt: false },
pendingModifiers: { ctrl: true, shift: false, alt: false },
}),
).toBe(false);
).toBe(true);
expect(
shouldInterceptDomTerminalKey({
key: "Escape",
ctrlKey: false,
altKey: false,
pendingModifiers: { ctrl: false, shift: false, alt: true },
}),
).toBe(true);
});
it("detects pending modifier state", () => {
+1 -6
View File
@@ -88,12 +88,7 @@ export function shouldInterceptDomTerminalKey(args: {
altKey: boolean;
pendingModifiers: PendingTerminalModifiers;
}): boolean {
return (
args.key.length > 1 ||
args.ctrlKey ||
args.altKey ||
hasPendingTerminalModifiers(args.pendingModifiers)
);
return hasPendingTerminalModifiers(args.pendingModifiers);
}
export function mergeTerminalModifiers(args: {