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

Can't input "@" on German keyboard with <AltGr> #1681

Closed
niklas88 opened this issue Oct 18, 2018 · 32 comments
Closed

Can't input "@" on German keyboard with <AltGr> #1681

niklas88 opened this issue Oct 18, 2018 · 32 comments

Comments

@niklas88
Copy link

I'm using alacritty on Windows with WSL via wslbridge (from wslttz 1.9.3)

On my Windows laptop I've got a German keyboard layout which has the right <alt> key called <AltGr> and that is used to input "@" via <AltGr> + <Q>. However in alacritty that combination does nothing.

@meltinglava
Copy link

meltinglava commented Oct 18, 2018

Can confirm that this does not work with norwegian layout as well.
Norwegian layout

meta-key button creates works
AltGr 0 }  
AltGr 2 @  
AltGr 3 £ yes
AltGr 4 $  
AltGr 5 yes
AltGr 7 {  
AltGr 8 [  
AltGr 9 ]  
AltGr \ ´ yes
AltGr ¨ ~ yes

@chrisduerr chrisduerr changed the title [Windows] Can't input "@" on German keyboard with <AltGr> Can't input "@" on German keyboard with <AltGr> Oct 18, 2018
@zacps
Copy link
Contributor

zacps commented Oct 19, 2018

Does using Ctrl-AltGr work?

@zacps zacps added the B - bug label Oct 19, 2018
@peddermaster2
Copy link

@zacps no.

@kpcyrd
Copy link

kpcyrd commented Oct 22, 2018

Just for the record, it seems this only applies to windows. I can insert @ with AltGr+Q without any issues on linux.

@ncreuschling
Copy link

It certainly applies to macOS (10.13.x).

@fculpo
Copy link

fculpo commented Oct 28, 2018

Same here on French Azerty, none of the AltGr combinations are working

@clarkema
Copy link

I'm seeing a version of this on macOS with a UK keyboard. AltGr + the number keys gives me the expected characters (AltGr + 2 = €, AltGr + 4 = ¢) for every number... except for AltGr + 3, which should give a #, and which is the only one I actually care about being able to enter into terminal.

This key combination just does nothing at all. On the plus side, I guess I have an excuse not to comment my code any more.

@thisconnect
Copy link

same here macos (just installed with brew)

[2018-12-19 06:28] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140333548684544)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 5, state: Pressed, virtual_keycode: Some(G), modifiers: ModifiersState { shift: false, ctrl: false, alt: true, logo: false } } } }
[2018-12-19 06:28] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140333548684544)), event: ReceivedCharacter('@') }

@niklas88
Copy link
Author

niklas88 commented Jan 9, 2019

This still persists on Windows 1809 with v0.2.5 and ConPTY but only in WSL, it works fine in PowerShell. Interestingly when running ssh (the Windows native one) from PowerShell it doesn't work in ssh either. Both works in cmd.exe

@chrisduerr
Copy link
Member

chrisduerr commented Jan 9, 2019

@niklas88 What output do you get when running alacritty --print-events and press AltGr + Q? I'd imagine it should be possible to work around this using a scancode mapping.

@ncreuschling
Copy link

ncreuschling commented Jan 9, 2019

macOS here (AltGr + L should result in @):

[2019-01-09 21:34] [INFO] glutin event: Awakened
[2019-01-09 21:34] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140367353710080)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 61, state: Pressed, virtual_keycode: Some(RAlt), modifiers: ModifiersState { shift: false, ctrl: false, alt: true, logo: false } } } }
[2019-01-09 21:34] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140367353710080)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 37, state: Pressed, virtual_keycode: Some(L), modifiers: ModifiersState { shift: false, ctrl: false, alt: true, logo: false } } } }
[2019-01-09 21:34] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140367353710080)), event: ReceivedCharacter('@') }
[2019-01-09 21:34] [INFO] glutin event: Awakened
[2019-01-09 21:34] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140367353710080)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 61, state: Released, virtual_keycode: Some(RAlt), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
[2019-01-09 21:34] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140367353710080)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 37, state: Released, virtual_keycode: Some(L), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }

@chrisduerr
Copy link
Member

chrisduerr commented Jan 9, 2019

@ncreuschling Since you're getting the event: ReceivedCharacter('@') output, it seems like a keybinding might be triggered that prevents this from working properly. Something similar shows up for @thisconnect who also appears to be running macos.

On Windows it might be different, so it might be helpful to get confirmation if ReceivedCharacter('@') is also printed.

In the following is a patch which applies additional debug information. It would be helpful if anyone who runs into the issue, but ReceivedCharacter('@') is printed, could run this. The --print-events flag is not necessary:

diff --git a/src/input.rs b/src/input.rs
index be8ed0d..d0922cc 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -707,6 +707,8 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
             self.ctx.write_to_pty(bytes);
 
             *self.ctx.received_count() += 1;
+        } else {
+            println!("CHARACTER HAS BEEN SUPPRESSED: '{}'", c);
         }
     }
 
@@ -735,6 +737,7 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
             };
 
             if is_triggered {
+                println!("TRIGGERED BINDING {:?} FOR {:?}", input, binding);
                 // binding was triggered; run the action
                 binding.execute(&mut self.ctx, false);
                 has_binding = true;

Note: This can be applied simply by saving it to a file and running git apply /path/to/file in the Alacritty git repository.

@ncreuschling
Copy link

ncreuschling commented Jan 9, 2019

First of all - thank you for your effort. The patched Alacritty (against c541155) now prints:

[2019-01-09 23:20] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140584855599968)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 61, state: Pressed, virtual_keycode: Some(RAlt), modifiers: ModifiersState { shift: false, ctrl: false, alt: true, logo: false } } } }
[2019-01-09 23:20] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140584855599968)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 37, state: Pressed, virtual_keycode: Some(L), modifiers: ModifiersState { shift: false, ctrl: false, alt: true, logo: false } } } }
[2019-01-09 23:20] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140584855599968)), event: ReceivedCharacter('@') }
[2019-01-09 23:20] [INFO] glutin event: Awakened
[2019-01-09 23:20] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140584855599968)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 61, state: Released, virtual_keycode: Some(RAlt), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
[2019-01-09 23:20] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140584855599968)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 37, state: Released, virtual_keycode: Some(L), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }

Then:

TRIGGERED BINDING KeyboardInput { scancode: 12, state: Pressed, virtual_keycode: Some(Q), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: true } } FOR Binding { mods: ModifiersState { shift: false, ctrl: false, alt: false, logo: true }, action: Quit, mode: NONE, notmode: NONE, trigger: Q }

I have not modified any settings in the key_bindings: block. They remain the same as the original alacritty_macos.yml.

@chrisduerr
Copy link
Member

@ncreuschling Looks like removing the Quit mapping on Command + Q should resolve this problem for you.

Though I'm not entirely sure why RAlt + L would trigger a keybinding for Command + Q.

I'd like some feedback on the Windows side of things, it would be interesting if this is caused by the same thing.

@ncreuschling I've got another patch if you're willing to help out. It seems like the --print-events code can't really be what's received by Alacritty, because the virtual keycodes are different from the bindings in the config. The following should print exactly which keys are received:

diff --git a/src/event.rs b/src/event.rs
index bada4f6..ea6f6b2 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -401,6 +401,7 @@ impl<N: Notify> Processor<N> {
                         processor.ctx.terminal.dirty = true;
                     },
                     KeyboardInput { input, .. } => {
+                        println!("NEW KEYBOARD INPUT: {:?}", input);
                         processor.process_key(input);
                         if input.state == ElementState::Pressed {
                             // Hide cursor while typing
diff --git a/src/input.rs b/src/input.rs
index be8ed0d..d0922cc 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -707,6 +707,8 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
             self.ctx.write_to_pty(bytes);
 
             *self.ctx.received_count() += 1;
+        } else {
+            println!("CHARACTER HAS BEEN SUPPRESSED: '{}'", c);
         }
     }
 
@@ -735,6 +737,7 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
             };
 
             if is_triggered {
+                println!("TRIGGERED BINDING {:?} FOR {:?}", input, binding);
                 // binding was triggered; run the action
                 binding.execute(&mut self.ctx, false);
                 has_binding = true;

Maybe that can get us a step closer to figuring out what exactly is going on. This should hopefully print the Command + Q keys that are actually getting triggered.

@ncreuschling
Copy link

I might have confused you: TRIGGERED BINDING happens when I close Alacritty (Command + Q is the shortcut to close an application).

Compilation is running, will report back…

@ncreuschling
Copy link

Here we go:

[2019-01-09 23:58] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140479870103120)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 61, state: Pressed, virtual_keycode: Some(RAlt), modifiers: ModifiersState { shift: false, ctrl: false, alt: true, logo: false } } } }
NEW KEYBOARD INPUT: KeyboardInput { scancode: 61, state: Pressed, virtual_keycode: Some(RAlt), modifiers: ModifiersState { shift: false, ctrl: false, alt: true, logo: false } }
[2019-01-09 23:58] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140479870103120)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 37, state: Pressed, virtual_keycode: Some(L), modifiers: ModifiersState { shift: false, ctrl: false, alt: true, logo: false } } } }
NEW KEYBOARD INPUT: KeyboardInput { scancode: 37, state: Pressed, virtual_keycode: Some(L), modifiers: ModifiersState { shift: false, ctrl: false, alt: true, logo: false } }
[2019-01-09 23:58] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140479870103120)), event: ReceivedCharacter('@') }
[2019-01-09 23:58] [INFO] glutin event: Awakened
[2019-01-09 23:58] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140479870103120)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 61, state: Released, virtual_keycode: Some(RAlt), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
NEW KEYBOARD INPUT: KeyboardInput { scancode: 61, state: Released, virtual_keycode: Some(RAlt), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } }
[2019-01-09 23:58] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140479870103120)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 37, state: Released, virtual_keycode: Some(L), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
NEW KEYBOARD INPUT: KeyboardInput { scancode: 37, state: Released, virtual_keycode: Some(L), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } }

@chrisduerr
Copy link
Member

I might have confused you: TRIGGERED BINDING happens when I close Alacritty (Command + Q is the shortcut to close an application).

Oh, that changes everything. So there is no TRIGGERED BINDING reported when pressing RAlt + L?

If there's no CHARACTER HAS BEEN SUPPRESSED being printed, then this probably isn't even a keyboard issue but something different entirely. I feel like we're getting somewhere here. :D

Looking at the key event of the L key, the modifier alt is true. So I'm pretty certain that the problem is that the \x1b escape sequence is sent before @ is inserted. This results in issues since \e@ is not a valid escape sequence (try running echo -e "\e@" and you'll see nothing gets printed).

From what I can tell we might need to fix this upstream and add a way to differentiate between AltGr and Alt as modifiers. Thanks for your help, this is likely the same on Windows! I'll think about possible work arounds and open an issue upstream (and link it here) if I don't find a solution.

@ncreuschling
Copy link

ncreuschling commented Jan 9, 2019

There is no TRIGGERED BINDING output. Sorry if I misled you here.

Again, thank you.

@chrisduerr
Copy link
Member

I've created rust-windowing/winit#756 for evaluating an upstream change to resolve this problem. There are alternative ways on how this can be resolved without requiring a change to winit, but I'd like to investigate an upstream approach first.

@niklas88
Copy link
Author

niklas88 commented Jan 10, 2019

Sorry it took me a bit to test this, I only have a Windows at work. I'm getting the following output for pressing <Alt Gr> <Q> on a German keyboard with Alacritty v0.2.5 and --print-events. This is in PowerShell where an "@" is actually printed which makes me think that your reasoning for an invalid escape code may be spot on. I usually only develop software on Linux but I can try compiling Alacritty on Windows with your debug patches if it is important.

[2019-01-10 10:28] [INFO] glutin event: Awakened
[2019-01-10 10:28] [INFO] glutin event: WindowEvent { window_id: WindowId(WindowId(0x406c2)), event: KeyboardInput { device_id: DeviceId(DeviceId(0)), input: KeyboardInput { scancode: 29, state: Pressed, virtual_keycode: Some(LControl), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
[2019-01-10 10:28] [INFO] glutin event: DeviceEvent { device_id: DeviceId(DeviceId(65601)), event: Key(KeyboardInput { scancode: 56, state: Pressed, virtual_keycode: Some(RAlt), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } }) }
[2019-01-10 10:28] [INFO] glutin event: WindowEvent { window_id: WindowId(WindowId(0x406c2)), event: KeyboardInput { device_id: DeviceId(DeviceId(0)), input: KeyboardInput { scancode: 56, state: Pressed, virtual_keycode: Some(RAlt), modifiers: ModifiersState { shift: false, ctrl: true, alt: true, logo: false } } } }
[2019-01-10 10:28] [INFO] glutin event: DeviceEvent { device_id: DeviceId(DeviceId(65601)), event: Key(KeyboardInput { scancode: 16, state: Pressed, virtual_keycode: Some(Q), modifiers: ModifiersState { shift: false, ctrl: true, alt: true, logo: false } }) }
[2019-01-10 10:28] [INFO] glutin event: WindowEvent { window_id: WindowId(WindowId(0x406c2)), event: KeyboardInput { device_id: DeviceId(DeviceId(0)), input: KeyboardInput { scancode: 16, state: Pressed, virtual_keycode: Some(Q), modifiers: ModifiersState { shift: false, ctrl: true, alt: true, logo: false } } } }
[2019-01-10 10:28] [INFO] glutin event: WindowEvent { window_id: WindowId(WindowId(0x406c2)), event: ReceivedCharacter('@') }
[2019-01-10 10:28] [INFO] glutin event: Awakened
[2019-01-10 10:28] [INFO] glutin event: Awakened
[2019-01-10 10:28] [INFO] glutin event: DeviceEvent { device_id: DeviceId(DeviceId(65601)), event: Key(KeyboardInput { scancode: 16, state: Released, virtual_keycode: Some(Q), modifiers: ModifiersState { shift: false, ctrl: true, alt: true, logo: false } }) }
[2019-01-10 10:28] [INFO] glutin event: WindowEvent { window_id: WindowId(WindowId(0x406c2)), event: KeyboardInput { device_id: DeviceId(DeviceId(0)), input: KeyboardInput { scancode: 16, state: Released, virtual_keycode: Some(Q), modifiers: ModifiersState { shift: false, ctrl: true, alt: true, logo: false } } } }
[2019-01-10 10:28] [INFO] glutin event: WindowEvent { window_id: WindowId(WindowId(0x406c2)), event: KeyboardInput { device_id: DeviceId(DeviceId(0)), input: KeyboardInput { scancode: 29, state: Released, virtual_keycode: Some(LControl), modifiers: ModifiersState { shift: false, ctrl: false, alt: true, logo: false } } } }
[2019-01-10 10:28] [INFO] glutin event: DeviceEvent { device_id: DeviceId(DeviceId(65601)), event: Key(KeyboardInput { scancode: 56, state: Released, virtual_keycode: Some(RAlt), modifiers: ModifiersState { shift: false, ctrl: false, alt: true, logo: false } }) }
[2019-01-10 10:28] [INFO] glutin event: WindowEvent { window_id: WindowId(WindowId(0x406c2)), event: KeyboardInput { device_id: DeviceId(DeviceId(0)), input: KeyboardInput { scancode: 56, state: Released, virtual_keycode: Some(RAlt), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }

@clarkema
Copy link

I'm seeing a version of this on macOS with a UK keyboard. AltGr + the number keys gives me the expected characters (AltGr + 2 = €, AltGr + 4 = ¢) for every number... except for AltGr + 3, which should give a #, and which is the only one I actually care about being able to enter into terminal.

This key combination just does nothing at all. On the plus side, I guess I have an excuse not to comment my code any more.

I got a bit further with this today while playing around with Alacritty on OS X again. It's not correct that the AltGr + 3 key combination does nothing at all -- I tried entering it in an Alacritty terminal containing a text-mode emacs instance, and emacs thought I'd entered M-#.

This suggests that AltGr + 3 is correctly yielding a # character, but with the Alt modifier incorrectly applied. Running with --print-events shows this happening:

[2019-02-13 14:32] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140377278525984)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 61, state: Pressed, virtual_keycode: Some(RAlt), modifiers: ModifiersState { shift: false, ctrl: false, alt: true, logo: false } } } }
[2019-02-13 14:32] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140377278525984)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 20, state: Pressed, virtual_keycode: Some(Key3), modifiers: ModifiersState { shift: false, ctrl: false, alt: true, logo: false } } } }
[2019-02-13 14:32] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140377278525984)), event: ReceivedCharacter('#') }
[2019-02-13 14:32] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140377278525984)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 20, state: Released, virtual_keycode: Some(Key3), modifiers: ModifiersState { shift: false, ctrl: false, alt: true, logo: false } } } }
[2019-02-13 14:32] [INFO] glutin event: WindowEvent { window_id: WindowId(Id(140377278525984)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 61, state: Released, virtual_keycode: Some(RAlt), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }

For now I've added the following keybinding to my config as a temporary fix:

 - { key: Key3,     mods: Alt,              chars: "#"                  }

This works, but is not ideal because it doesn't differentiate between Right and Left Alt. Left Alt + another key should produce that key plus the Alt modifier; Right Alt plus another key should not.

@ncreuschling
Copy link

Indeed, this works for me when alt_send_esc: false is set.

Thank you to everyone involved.

@bostich83
Copy link

Hi ncreuschling,
could you please so kind and post a sample config? It's not really clear to me where you've put alt_send_esc to?

Thanks!

@ncreuschling
Copy link

This was/is an entry in my .alacritty.yml file.

@bostich83
Copy link

Thank you for the quick response!
I don't have such a file. There are tons of ".travis.yml" files, but none is called .alacritty.yml.

@thisconnect
Copy link

This was/is an entry in my .alacritty.yml file.

doesn't work for me :( , proabably something wrong with my .alacritty.yml file. I didn't have one.

Why was this closed, isn't this issue affecting every macos user?

@ncreuschling
Copy link

Why was this closed, isn't this issue affecting every macos user?

The problem (@ on German keyboard) has been resolved thus the issue was closed.

@bostich83
Copy link

Could you please post the path and content of that file?
Thank you!

@ncreuschling
Copy link

I don't have such a file. There are tons of ".travis.yml" files, but none is called .alacritty.yml.

Could you please post the path and content of that file?

Please follow the instructions in the README.md.

@ncreuschling
Copy link

ncreuschling commented Aug 30, 2019

Could you please post the path and content of that file?

See here.

@bostich83
Copy link

OMG. I'am very sorry, but i've posted to the wrong repo -.-.

Forget what i was asking for. SORRY!

@ncreuschling
Copy link

No problem.

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

No branches or pull requests