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
This commit is contained in:
James Hall 2016-08-02 01:08:51 +01:00 committed by GitHub
parent c9fe3d82db
commit 519210ece6

View file

@ -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;
}