Browse Source

Fix MapConsoleKeyInfo not working with Esc properly

tznind 9 months ago
parent
commit
b30c92bceb
1 changed files with 12 additions and 0 deletions
  1. 12 0
      Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs

+ 12 - 0
Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs

@@ -970,6 +970,18 @@ public static class EscSeqUtils
 
                 break;
             case uint n when n > 0 && n <= KeyEsc:
+                if (n == KeyEsc)
+                {
+                    key= ConsoleKey.Escape;
+
+                    newConsoleKeyInfo = new ConsoleKeyInfo (
+                                                            consoleKeyInfo.KeyChar,
+                                                            key,
+                                                            (consoleKeyInfo.Modifiers & ConsoleModifiers.Shift) != 0,
+                                                            (consoleKeyInfo.Modifiers & ConsoleModifiers.Alt) != 0,
+                                                            (consoleKeyInfo.Modifiers & ConsoleModifiers.Control) != 0);
+                }
+                else
                 if (consoleKeyInfo.Key == 0 && consoleKeyInfo.KeyChar == '\r')
                 {
                     key = ConsoleKey.Enter;