fix(web): allow pasting with cmd-v (#4321)

This commit is contained in:
Thomas Linford 2025-07-30 11:54:40 +02:00 committed by GitHub
parent be20acaa3e
commit aaa843eee0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 6 deletions

View file

@ -2,7 +2,8 @@
* Input handling for terminal events * Input handling for terminal events
*/ */
import { encode_kitty_key } from './keyboard.js'; import { encode_kitty_key } from "./keyboard.js";
import { isMac } from "./utils.js";
/** /**
* Set up all input handlers for the terminal * Set up all input handlers for the terminal
@ -21,6 +22,11 @@ export function setupInputHandlers(term, sendFunction) {
// pass ctrl-shift-v onwards so that paste is interpreted by xterm.js // pass ctrl-shift-v onwards so that paste is interpreted by xterm.js
return; return;
} }
if (isMac() && ev.key == "v" && ev.metaKey) {
// pass cmd-v onwards so that paste is interpreted by xterm.js
return;
}
let modifiers_count = 0; let modifiers_count = 0;
let shift_keycode = 16; let shift_keycode = 16;
let alt_keycode = 17; let alt_keycode = 17;
@ -107,7 +113,7 @@ export function setupInputHandlers(term, sendFunction) {
}); });
// Context menu handler // Context menu handler
document.addEventListener('contextmenu', function(event) { document.addEventListener("contextmenu", function (event) {
if (event.altKey) { if (event.altKey) {
// this is so that when the user does an alt-right-click to ungroup panes, the context menu will not appear // this is so that when the user does an alt-right-click to ungroup panes, the context menu will not appear
event.preventDefault(); event.preventDefault();

View file

@ -9,3 +9,10 @@
export function is_https() { export function is_https() {
return document.location.protocol === "https:"; return document.location.protocol === "https:";
} }
export function isMac() {
if (navigator.userAgentData && navigator.userAgentData.platform) {
return navigator.userAgentData.platform === "macOS";
}
return navigator.platform.toUpperCase().includes("MAC");
}