Skip to content

Commit 1880da5

Browse files
committed
fix: app keybindings to work in terminal tabs
1 parent fe9d32a commit 1880da5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/components/terminal/terminal.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,29 @@ export default class TerminalComponent {
140140
return false;
141141
}
142142

143+
// For app-wide keybindings, dispatch them to the app's keyboard handler
144+
if (event.ctrlKey || event.altKey || event.metaKey) {
145+
// Skip modifier-only keys
146+
if (["Control", "Alt", "Meta", "Shift"].includes(event.key)) {
147+
return true;
148+
}
149+
const appEvent = new KeyboardEvent("keydown", {
150+
key: event.key,
151+
ctrlKey: event.ctrlKey,
152+
shiftKey: event.shiftKey,
153+
altKey: event.altKey,
154+
metaKey: event.metaKey,
155+
bubbles: true,
156+
cancelable: true,
157+
});
158+
159+
// Dispatch to document so it gets picked up by the app's keyboard handler
160+
document.dispatchEvent(appEvent);
161+
162+
// Return false to prevent terminal from processing this key
163+
return false;
164+
}
165+
143166
// Return true to allow normal processing for other keys
144167
return true;
145168
});

0 commit comments

Comments
 (0)