diff --git a/Terminal.Gui/ConsoleDrivers/NetDriver.cs b/Terminal.Gui/ConsoleDrivers/NetDriver.cs index 811426f44..156c08f9d 100644 --- a/Terminal.Gui/ConsoleDrivers/NetDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/NetDriver.cs @@ -177,7 +177,15 @@ namespace Terminal.Gui { ConsoleKeyInfo newConsoleKeyInfo = default; while (true) { - ConsoleKeyInfo consoleKeyInfo = Console.ReadKey (true); + ConsoleKeyInfo consoleKeyInfo; + + try { + consoleKeyInfo = Console.ReadKey (true); + } catch (InvalidOperationException ex) { + + return; + } + if ((consoleKeyInfo.KeyChar == (char)Key.Esc && !isEscSeq) || (consoleKeyInfo.KeyChar != (char)Key.Esc && isEscSeq)) { if (cki == null && consoleKeyInfo.KeyChar != (char)Key.Esc && isEscSeq) {