diff --git a/lib/hterm.js b/lib/hterm.js index f0e8852fb71b..cce4b46bcb3a 100644 --- a/lib/hterm.js +++ b/lib/hterm.js @@ -223,22 +223,29 @@ hterm.Keyboard.prototype.onKeyDown_ = function (e) { e.preventDefault(); } + // hterm shouldn't consume a hyper accelerator if (e.altKey || e.metaKey || isAccelerator(e)) { - // hterm shouldn't consume a hyper accelerator - // // Was the hyperCaret removed for selectAll - if (e.key === 'v' && !this.terminal.cursorNode_.contains(this.hyperCaret)) { + // If the `hyperCaret` was removed on `selectAll`, we need to insert it back + if (e.key === 'v' && this.terminal.hyperCaret.parentNode !== this.terminal.cursorNode_) { this.terminal.focusHyperCaret(); } return; } // Test for valid keys in order to accept clear status - if (e.code !== 'Control' && e.key !== 'Shift' && e.code !== 'CapsLock' && e.key !== 'Dead') { + const clearBlacklist = [ + 'control', + 'shift', + 'capslock', + 'dead' + ]; + if (!clearBlacklist.includes(e.code.toLowerCase()) && + !clearBlacklist.includes(e.key.toLowerCase())) { selection.clear(this.terminal); } - // Was the hyperCaret removed for selectAll - if (!this.terminal.cursorNode_.contains(this.hyperCaret)) { + // If the `hyperCaret` was removed on `selectAll`, we need to insert it back + if (this.terminal.hyperCaret.parentNode !== this.terminal.cursorNode_) { this.terminal.focusHyperCaret(); } return oldKeyDown.call(this, e);