term.js
term.js copied to clipboard
Improve german keyboard (special characters) support
Hey, I've added a few keyDown actions to improve the special characters support ([,],|,{,},~,@,€,) under windows, linux and mac when using a German keyboard.
I sometimes had to use the keyIdentifier instead of the keyCode due to ambiguous and strange keyCodes using ALT + "number line" on a german mac keyboard. For instance, ALT + 5 produced the same keyCode as ALT + 8.
Furthermore, I saw that you sometimes check for a keyCode and then weather ALT or CRTL has been pressed as well. There are also other cases where you check weather ALT or CRTL has been pressed and then the keyCode. I decided to use the latter version to have a coherent block for combinations and hope it's okay for you.
Since some key combinations have different meanings on different keyboard layouts, this kind of special treatment won't go well if other languages would be added. Do you have any ideas how to improve this in the future? As far as I know, detecting the keyboard layout through JavaScript is not possible. Maybe using a DOM element such as an input field (which works fine on all operation systems and keyboard layouts because of the browser interpretation) with a lot of styling could be used instead. Any thoughts about that?
Thanks for your great work!!
I tested your patch on French keyboard, it solve few AltGr chars (but not all) Need to make same trick for French.
Can you try an empty "if (ev.altKey && ev.ctrlKey) {" ? All work for me (french) with this patch :
I added "if (ev.altKey && ev.ctrlKey) {" before "if (ev.ctrlKey) {" and I replaced with "} else if (ev.ctrlKey) {"
To work this part of code need "ev.ctrlKey" without "ev.altKey" or reciprocally
There is another equivalent code : "ev.ctrlKey and not ev.altKey" / "ev.altKey and not ev.ctrlKey" for the two "if".
Diff with current master :
(root|/var/www/js) diff term.js term.js.master
2761,2763c2761
< if (ev.altKey && ev.ctrlKey) {
<
< } else if (ev.ctrlKey) {
---
> if (ev.ctrlKey) {
Working code :
// F11
case 122:
key = '\x1b[23~';
break;
// F12
case 123:
key = '\x1b[24~';
break;
default:
// a-z and space
if (ev.altKey && ev.ctrlKey) { // Added
// Empty
} else if (ev.ctrlKey) {
if (ev.keyCode >= 65 && ev.keyCode <= 90) {
// Ctrl-A
if (this.screenKeys) {
if (!this.prefixMode && !this.selectMode && ev.keyCode === 65) {
this.enterPrefix();
return cancel(ev);
}
}
// Ctrl-V
if (this.prefixMode && ev.keyCode === 86) {
this.leavePrefix();
return;
}
// Ctrl-C
Could you just tell me your desired key combinations? I'll check afterwards how I could implement them most effectively.
Hello, on Firefox, all French AltGr + "234567890)=" combinations work with this "EMPTY" patch.
But there is no effect on Internet Explorer (I check on recent versions of any browser only, crap code for old IE is not needed).
I tested few javascript keypress/keydown event monitor, all woth with AltGr on FF&IE but I don't understand at this time why there is a I.E bug in term.js
Thanks, Pascal
I tried to fix to handle all the non-English characters. https://github.com/chjj/term.js/pull/97