Fix international tilde character, and ` and ´ (#584)

* This fixes many more keyboard layouts
* Make backticks work on German keyboards
* Add italian keyboard layout, and also log when uncaught dead key occurs
This commit is contained in:
James Hall 2016-08-10 18:37:35 +01:00 committed by GitHub
parent f24c1a5499
commit cb651f6492

View file

@ -34,26 +34,55 @@ hterm.Keyboard.prototype.onKeyDown_ = function (e) {
* These keys are sent through as 'Dead' keys, as they're used as modifiers. * These keys are sent through as 'Dead' keys, as they're used as modifiers.
* Ignore that and insert the correct character. * Ignore that and insert the correct character.
*/ */
if (e.key === 'Dead' && e.code === 'Quote' && e.shiftKey === false) { if (e.key === 'Dead') {
if (e.code === 'Quote' && e.shiftKey === false) {
this.terminal.onVTKeystroke("'"); this.terminal.onVTKeystroke("'");
return; return;
} }
if (e.key === 'Dead' && e.code === 'Quote' && e.shiftKey === true) { if (e.code === 'Quote' && e.shiftKey === true) {
this.terminal.onVTKeystroke('"'); this.terminal.onVTKeystroke('"');
return; return;
} }
if (e.key === 'Dead' && (e.code === 'IntlBackslash' || e.code === 'Backquote') && e.shiftKey === true) { if ((e.code === 'IntlBackslash' || e.code === 'Backquote') && e.shiftKey === true) {
this.terminal.onVTKeystroke('~'); this.terminal.onVTKeystroke('~');
return; return;
} }
if (e.key === 'Dead' && (e.code === 'IntlBackslash' || e.code === 'Backquote') && e.shiftKey === false) { // This key is also a tilde on all tested keyboards
if (e.code === 'KeyN' && e.altKey === true) {
this.terminal.onVTKeystroke('~');
return;
}
if ((e.code === 'IntlBackslash' || e.code === 'Backquote') && e.shiftKey === false) {
this.terminal.onVTKeystroke('`'); this.terminal.onVTKeystroke('`');
return; return;
} }
if (e.key === 'Dead' && e.code === 'Digit6') { if (e.code === 'Digit6') {
this.terminal.onVTKeystroke('^'); this.terminal.onVTKeystroke('^');
return; return;
} }
// German keyboard layout
if (e.code === 'Equal' && e.shiftKey === false) {
this.terminal.onVTKeystroke('´');
return;
}
if (e.code === 'Equal' && e.shiftKey === true) {
this.terminal.onVTKeystroke('`');
return;
}
// Italian keyboard layout
if (e.code === 'Digit9' && e.altKey === true) {
this.terminal.onVTKeystroke('`');
return;
}
if (e.code === 'Digit8' && e.altKey === true) {
this.terminal.onVTKeystroke('´');
// To fix issue with changing the terminal prompt
e.preventDefault();
return;
}
console.warn('Uncaught dead key on international keyboard', e);
}
if (e.metaKey || e.altKey) { if (e.metaKey || e.altKey) {
return; return;
} }