From 065bd4c5aeb53d98321c8dd2f56352ab169e063e Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Wed, 29 May 2019 22:24:02 +0200 Subject: [PATCH] webrepl.html: Allow typing option-modified characters on macOS. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On macOS, don’t hijack the option key (mapped to "alt" in the event API) to send escape sequences. It's a character modifier, not a command modifier, and required to type vital characters like [ or \ on some keyboard layouts. --- term.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/term.js b/term.js index dc535cc..4f8bedb 100644 --- a/term.js +++ b/term.js @@ -2835,7 +2835,7 @@ Terminal.prototype.keyDown = function(ev) { // ^] - group sep key = String.fromCharCode(29); } - } else if (ev.altKey) { + } else if (ev.altKey && !this.isMac) { if (ev.keyCode >= 65 && ev.keyCode <= 90) { key = '\x1b' + String.fromCharCode(ev.keyCode + 32); } else if (ev.keyCode === 192) { @@ -2895,7 +2895,7 @@ Terminal.prototype.keyPress = function(ev) { return false; } - if (!key || ev.ctrlKey || ev.altKey || ev.metaKey) return false; + if (!key || ev.ctrlKey || (ev.altKey && !this.isMac) || ev.metaKey) return false; key = String.fromCharCode(key);