From 519210ece6709ba2b7ed3bb6cc5fece3c6a68903 Mon Sep 17 00:00:00 2001 From: James Hall Date: Tue, 2 Aug 2016 01:08:51 +0100 Subject: [PATCH] Initial support for pressing ~ ^ " ' ` on international keyboard layouts until composed characters lands (#521) * International keyboard support fixes * Use correct tilde character * Add correct caret char * Add alternate key code mapping for ~ and ` - credit: fecabianchi --- lib/hterm.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/hterm.js b/lib/hterm.js index 27ad71bf..7c9ab102 100644 --- a/lib/hterm.js +++ b/lib/hterm.js @@ -29,6 +29,31 @@ hterm.Terminal.prototype.copySelectionToClipboard = function () { // hyperterm and not the terminal itself const oldKeyDown = hterm.Keyboard.prototype.onKeyDown_; hterm.Keyboard.prototype.onKeyDown_ = function (e) { + /** + * Add fixes for U.S. International PC Keyboard layout + * These keys are sent through as 'Dead' keys, as they're used as modifiers. + * Ignore that and insert the correct character. + */ + if (e.key === 'Dead' && e.code === 'Quote' && e.shiftKey === false) { + this.terminal.onVTKeystroke("'"); + return; + } + if (e.key === 'Dead' && e.code === 'Quote' && e.shiftKey === true) { + this.terminal.onVTKeystroke('"'); + return; + } + if (e.key === 'Dead' && (e.code === 'IntlBackslash' || e.code === 'Backquote') && e.shiftKey === true) { + this.terminal.onVTKeystroke('~'); + return; + } + if (e.key === 'Dead' && (e.code === 'IntlBackslash' || e.code === 'Backquote') && e.shiftKey === false) { + this.terminal.onVTKeystroke('`'); + return; + } + if (e.key === 'Dead' && e.code === 'Digit6') { + this.terminal.onVTKeystroke('^'); + return; + } if (e.metaKey || e.altKey) { return; }