Repository: alacritty/alacritty (language: rust)

Issue:
Extended Ascii characters don't work with modifiers.
Description:
I tried to use some extended ascii character for a keybind (meta-à or alt-à) in a TUI application (weechat), 
but meta-à is recognized as just à.
This binding works in urxvt, terminator, and also outside of weechat, if we use for example emacs -nw.
This is probably the same thing for é, è, ê, ç, to give a few examples.

Expected Behaviour:
meta-à or any other extended character combined with any modifier should work and be passed to the TUI application.

### System

OS: Archlinux
Version:  alacritty 0.13.1 (fe2a3c56)
Linux/BSD: X11

### Logs

Keyboard and bindings:
```
[78.987553759s] [INFO ] [alacritty] winit event: NewEvents(WaitCancelled { start: Instant { tv_sec: 778951, tv_nsec: 777711584 }, requested_resume: None })
[78.987596149s] [INFO ] [alacritty] winit event: WindowEvent { window_id: WindowId(WindowId(35651587)), event: KeyboardInput { device_id: DeviceId(X(DeviceId(3))), event: KeyEvent { physical_key: Code(AltLeft), logical_key: Named(Alt), text: None, location: Left, state: Pressed, repeat: false, platform_specific: KeyEventExtra { key_without_modifiers: Named(Alt), text_with_all_modifiers: None } }, is_synthetic: false } }
[78.987619941s] [INFO ] [alacritty] winit event: WindowEvent { window_id: WindowId(WindowId(35651587)), event: ModifiersChanged(Modifiers { state: ModifiersState(ALT), pressed_mods: ModifiersKeys(0x0) }) }
[78.987630739s] [INFO ] [alacritty] winit event: AboutToWait
[78.988458098s] [INFO ] [alacritty] winit event: NewEvents(WaitCancelled { start: Instant { tv_sec: 778955, tv_nsec: 274830673 }, requested_resume: None })
[78.988478916s] [INFO ] [alacritty] winit event: WindowEvent { window_id: WindowId(WindowId(35651587)), event: KeyboardInput { device_id: DeviceId(X(DeviceId(3))), event: KeyEvent { physical_key: Code(KeyZ), logical_key: Character("à"), text: Some("à"), location: Standard, state: Pressed, repeat: false, platform_specific: KeyEventExtra { key_without_modifiers: Character("à"), text_with_all_modifiers: Some("à") } }, is_synthetic: false } }
[78.988513444s] [INFO ] [alacritty] winit event: AboutToWait
[78.988812444s] [INFO ] [alacritty] winit event: NewEvents(WaitCancelled { start: Instant { tv_sec: 778955, tv_nsec: 275714522 }, requested_resume: None })
[78.988827799s] [INFO ] [alacritty] winit event: UserEvent(Event { window_id: Some(WindowId(WindowId(35651587))), payload: Terminal(Wakeup) })
[78.988839803s] [INFO ] [alacritty] winit event: WindowEvent { window_id: WindowId(WindowId(35651587)), event: RedrawRequested }
[78.990448942s] [INFO ] [alacritty] winit event: AboutToWait
[78.990477215s] [INFO ] [alacritty] winit event: NewEvents(WaitCancelled { start: Instant { tv_sec: 778955, tv_nsec: 277643553 }, requested_resume: None })
[78.990486085s] [INFO ] [alacritty] winit event: UserEvent(Event { window_id: Some(WindowId(WindowId(35651587))), payload: Frame })
[78.990491423s] [INFO ] [alacritty] winit event: AboutToWait
```


Discussion / hints:
@chrisduerr I'm not sure it's a duplicate though, iirc we don't send `ESC` for some unicode sequences?
Can someone point to the original issue you are referring to ?

Could you try something like that

```diff
diff --git a/alacritty/src/input/keyboard.rs b/alacritty/src/input/keyboard.rs
index afb23eb5..71af6201 100644
--- a/alacritty/src/input/keyboard.rs
+++ b/alacritty/src/input/keyboard.rs
@@ -126,7 +126,7 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {
                     self.ctx.modifiers().state().alt_key()
                 }
             },
-            _ => text.len() == 1 && alt_send_esc,
+            _ => text.chars().count() == 1 && alt_send_esc,
         }
     }
 
```

Also, we'd probably need to test other terms... What do you think about this, @chrisduerr ? 
Your patch seems to work fine.
Thank you.

EDIT: 
sry, i didn't test it properly, the patch indeed works for the alt modifier, but not for the control modifier.

With the hint of ESC, i found this issue : https://github.com/alacritty/alacritty/issues/4862
by applying the configuration of the last message, it seems to work (with the non patched alacritty).
Without the message of kchibisov, i wouldn't have found it, because i didn't know alt is sending esc.
Anyway, this is a rather confusing default behavior, you said (chrisduerr) in the issue i mention that you were not sure if things should be kept the same way they are in Xterm.
https://github.com/alacritty/alacritty/issues/4862#issuecomment-812206362
So maybe we could change the default (with the patch of kchibisov), or add a section in the documentation for that, with the keybind configuration as an example ?

What do you think ?
> I'm not sure it's a duplicate though, iirc we don't send ESC for some unicode sequences?

It's a known (and intentional) limitation, I'm pretty certain there are other issues about it elsewhere.

> Also, we'd probably need to test other terms... What do you think about this, @chrisduerr ?

I know it is the way it is for a reason, I just don't remember that reason. It might have been related to macOS' alt handling, so I could probably be convinced to remove this.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cbbd4bb8fd1..d61e0e9ea91 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 
 ### Changed
 
+- Pressing `Alt` with unicode input will now add `ESC` like for ASCII input
 - No unused-key warnings will be emitted for OS-specific config keys
 - Use built-in font for sextant symbols from `U+1FB00` to `U+1FB3B`
 - Kitty encoding is not used anymore for uncommon keys unless the protocol enabled
diff --git a/alacritty/src/input/keyboard.rs b/alacritty/src/input/keyboard.rs
index afb23eb5053..b4c357410ce 100644
--- a/alacritty/src/input/keyboard.rs
+++ b/alacritty/src/input/keyboard.rs
@@ -126,7 +126,7 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {
                     self.ctx.modifiers().state().alt_key()
                 }
             },
-            _ => text.len() == 1 && alt_send_esc,
+            _ => alt_send_esc && text.chars().count() == 1,
         }
     }
 


Test patch: