From 524db02228f4bf9eababb7f2932f2ed898147bc7 Mon Sep 17 00:00:00 2001 From: runarberg Date: Thu, 9 Jun 2016 13:05:50 +0000 Subject: [PATCH] Fix Ctrl/Shift + insert copy/paste Many systems (including MS Windows and many linuxes) map `` + `` to copy and ` + ` to paste. That serves as a handy fallback when the more common ` + C` and ` + 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. --- src/xterm.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/xterm.js b/src/xterm.js index b17437cc..3a8da861 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -519,6 +519,11 @@ term.leaseContentEditable(); } } + + if (!term.isMac && ev.keyCode == 45 && ev.shiftKey && !ev.ctrlKey) { + // Shift + Insert pastes on windows and many linuxes + term.leaseContentEditable(); + } }); /** @@ -2387,7 +2392,11 @@ break; // insert case 45: - key = '\x1b[2~'; + if (!ev.shiftKey && !ev.ctrlKey) { + // or + are used to + // copy-paste on some systems. + key = '\x1b[2~'; + } break; // home case 36: