mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-03-27 09:45:53 +00:00
Fix terminal keyboard event handling to allow browser shortcuts
The terminal component was aggressively preventing default on ALL keyboard events, blocking important browser shortcuts like F12 (DevTools), Ctrl+C/Ctrl+V (copy/paste), and Ctrl+F (find). Updated the keyboard handler to: - Allow F12 and Ctrl+Shift+I/Cmd+Alt+I for DevTools - Allow common browser shortcuts like Ctrl+A, Ctrl+F, Ctrl+R, etc. - Allow Alt+Tab and Cmd+Tab for window switching - Only preventDefault on keys that are actually handled by the terminal This preserves terminal functionality while restoring essential browser shortcuts. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5ce76f828f
commit
bbd079c052
1 changed files with 40 additions and 1 deletions
|
|
@ -40,6 +40,45 @@ export class SessionView extends LitElement {
|
|||
private keyboardHandler = (e: KeyboardEvent) => {
|
||||
if (!this.session) return;
|
||||
|
||||
// Allow important browser shortcuts to pass through
|
||||
const isMacOS = navigator.platform.toLowerCase().includes('mac');
|
||||
|
||||
// Allow F12 and Ctrl+Shift+I (DevTools)
|
||||
if (
|
||||
e.key === 'F12' ||
|
||||
(!isMacOS && e.ctrlKey && e.shiftKey && e.key === 'I') ||
|
||||
(isMacOS && e.metaKey && e.altKey && e.key === 'I')
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Allow Ctrl+A (select all), Ctrl+F (find), Ctrl+R (refresh), etc.
|
||||
if (
|
||||
!isMacOS &&
|
||||
e.ctrlKey &&
|
||||
!e.shiftKey &&
|
||||
['a', 'f', 'r', 'l', 't', 'w', 'n'].includes(e.key.toLowerCase())
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Allow Cmd+A, Cmd+F, Cmd+R, etc. on macOS
|
||||
if (
|
||||
isMacOS &&
|
||||
e.metaKey &&
|
||||
!e.shiftKey &&
|
||||
!e.altKey &&
|
||||
['a', 'f', 'r', 'l', 't', 'w', 'n'].includes(e.key.toLowerCase())
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Allow Alt+Tab, Cmd+Tab (window switching)
|
||||
if ((e.altKey || e.metaKey) && e.key === 'Tab') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only prevent default for keys we're actually going to handle
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
|
|
@ -450,7 +489,7 @@ export class SessionView extends LitElement {
|
|||
const response = await fetch(`/api/sessions/${this.session.id}/resize`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ width: cols, height: rows }),
|
||||
body: JSON.stringify({ cols: cols, rows: rows }),
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue