Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve german keyboard (special characters) support #85

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

eickeee
Copy link

@eickeee eickeee commented Aug 18, 2015

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!!

eickeee and others added 2 commits August 18, 2015 19:20
@VigibotDev
Copy link

I tested your patch on French keyboard, it solve few AltGr chars (but not all)
Need to make same trick for French.

@VigibotDev
Copy link

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

@eickeee
Copy link
Author

eickeee commented Oct 12, 2015

Could you just tell me your desired key combinations? I'll check afterwards how I could implement them most effectively.

@VigibotDev
Copy link

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

@yoshiokatsuneo
Copy link

I tried to fix to handle all the non-English characters. #97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants