diff --git a/config/src/lib.rs b/config/src/lib.rs index e2f6dc8bc..b2e559b98 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -843,6 +843,9 @@ pub struct Config { #[serde(default = "default_true")] pub send_composed_key_when_right_alt_is_pressed: bool, + #[serde(default)] + pub treat_left_ctrlalt_as_altgr: bool, + /// If true, the `Backspace` and `Delete` keys generate `Delete` and `Backspace` /// keypresses, respectively, rather than their normal keycodes. /// On macOS the default for this is true because its Backspace key diff --git a/docs/config/keys.md b/docs/config/keys.md index 5f7d4350f..bb9478431 100644 --- a/docs/config/keys.md +++ b/docs/config/keys.md @@ -100,6 +100,24 @@ return { } ``` +### Microsoft Windows and Ctrl-Alt <-> AltGr + +*since: nightly* + +If you are using a layout with an *AltGr* key, you may experience issues +when running inside a VNC session, because VNC emulates the AltGr keypresses +by sending plain *Ctrl-Alt* keys, which won't be understood as AltGr. + +To fix this behavior you can tell WezTerm to treat left *Ctrl-Alt* keys as +*AltGr* with the option `treat_left_ctrlalt_as_altgr`. Note that the key bindings using separate Ctrl and Alt won't be triggered anymore. + +```lua +return { + treat_left_ctrlalt_as_altgr = true +} +``` + + ### Defining Assignments for key combinations that may be composed When a key combination produces a composed key result, wezterm will look up diff --git a/wezterm-gui/src/window_config.rs b/wezterm-gui/src/window_config.rs index 3c231cc22..eb0ebf034 100644 --- a/wezterm-gui/src/window_config.rs +++ b/wezterm-gui/src/window_config.rs @@ -32,6 +32,10 @@ impl WindowConfiguration for ConfigInstance { self.0.send_composed_key_when_right_alt_is_pressed } + fn treat_left_ctrlalt_as_altgr(&self) -> bool { + self.0.treat_left_ctrlalt_as_altgr + } + fn enable_wayland(&self) -> bool { self.0.enable_wayland } @@ -87,6 +91,10 @@ impl WindowConfiguration for ConfigBridge { global().send_composed_key_when_right_alt_is_pressed() } + fn treat_left_ctrlalt_as_altgr(&self) -> bool { + global().treat_left_ctrlalt_as_altgr() + } + fn enable_wayland(&self) -> bool { global().enable_wayland() } diff --git a/window/src/configuration.rs b/window/src/configuration.rs index f4374cf1e..8734beee3 100644 --- a/window/src/configuration.rs +++ b/window/src/configuration.rs @@ -14,6 +14,10 @@ pub trait WindowConfiguration { true } + fn treat_left_ctrlalt_as_altgr(&self) -> bool { + false + } + // Applies to Windows only. // For macos, see send_composed_key_when_XXX_alt_is_pressed fn use_dead_keys(&self) -> bool { diff --git a/window/src/os/windows/window.rs b/window/src/os/windows/window.rs index 912d77dbe..fa0939436 100644 --- a/window/src/os/windows/window.rs +++ b/window/src/os/windows/window.rs @@ -1570,7 +1570,7 @@ unsafe fn key(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) -> Option Option