From 6432a1927a80c44255940851d3d70d0d86d4faf4 Mon Sep 17 00:00:00 2001 From: Harri Taylor <7202769+harritaylor@users.noreply.github.com> Date: Mon, 3 Jul 2023 10:17:28 +0100 Subject: [PATCH] feat(editor): Allow Ctrl-[ to function as Escape Issue: https://github.com/helix-editor/helix/issues/6551 --- helix-view/src/input.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/helix-view/src/input.rs b/helix-view/src/input.rs index d8832adce11e..4ae52bf73f9f 100644 --- a/helix-view/src/input.rs +++ b/helix-view/src/input.rs @@ -488,6 +488,16 @@ impl From for KeyEvent { code: KeyCode::Tab, modifiers, } + } else if code == crossterm::event::KeyCode::Char('[') + && modifiers.contains(crossterm::event::KeyModifiers::CONTROL) + { + // Support Ctrl-[ as ESC for terminals that support sending Ctrl-[ + let mut modifiers = modifiers; + modifiers.remove(crossterm::event::KeyModifiers::CONTROL); + Self { + code: KeyCode::Esc, + modifiers: modifiers.into(), + } } else { Self { code: code.into(),