Skip to content

Commit 74b1a50

Browse files
author
runarberg
committed
Fix Ctrl/Shift + insert copy/paste
Many systems (including MS Windows and many linuxes) map `<Ctrl>` + `<Insert>` to copy and `<Shift> + <Insert>` to paste. That serves as a handy fallback when the more common `<Ctrl> + C` and `<Ctrl> + V` keybindings have their default prevented to send signals to the terminal. Currently all keydown-events with the insert key send `\x1b[2~` to the terminal. This commit won't send that key if either the `shiftKey` or the `ctrlKey` are present. Instead it will enable `contentEditable` to allow for pasting.
1 parent 136c838 commit 74b1a50

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/xterm.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,11 @@
501501
term.leaseContentEditable();
502502
}
503503
}
504+
505+
if (!term.isMac && ev.keyCode == 45 && ev.shiftKey && !ev.ctrlKey) {
506+
// Shift + Insert pastes on windows and many linuxes
507+
term.leaseContentEditable();
508+
}
504509
});
505510

506511
/**
@@ -2363,7 +2368,11 @@
23632368
break;
23642369
// insert
23652370
case 45:
2366-
key = '\x1b[2~';
2371+
if (!ev.shiftKey && !ev.ctrlKey) {
2372+
// <Ctrl> or <Shift> + <Insert> are used to
2373+
// copy-paste on some systems.
2374+
key = '\x1b[2~';
2375+
}
23672376
break;
23682377
// home
23692378
case 36:

0 commit comments

Comments
 (0)