From 24f01f22baf8c7cb9c0eaee91f0a839032545eb9 Mon Sep 17 00:00:00 2001 From: Edward Wright Date: Fri, 9 Jul 2021 09:30:05 -0400 Subject: [PATCH] Added outgoing processing for cursor keys. --- SimplySerial/SimplySerial.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/SimplySerial/SimplySerial.cs b/SimplySerial/SimplySerial.cs index 8260c7f..12548d6 100644 --- a/SimplySerial/SimplySerial.cs +++ b/SimplySerial/SimplySerial.cs @@ -34,6 +34,13 @@ namespace SimplySerial static int bufferSize = 102400; static DateTime lastFlush = DateTime.Now; + static Dictionary specialKeys = new Dictionary + { + { ConsoleKey.UpArrow, "\x1B[A" }, + { ConsoleKey.DownArrow, "\x1B[B" }, + { ConsoleKey.RightArrow, "\x1B[C" }, + { ConsoleKey.LeftArrow, "\x1B[D" } + }; static void Main(string[] args) { @@ -216,6 +223,10 @@ namespace SimplySerial Thread.Sleep(150); // sort of cheating here - by adding this delay we ensure that when we process the receive buffer it will contain the correct backspace control sequence } + // check for keys that require special processing (cursor keys, etc.) + else if (specialKeys.ContainsKey(keyInfo.Key)) + serialPort.Write(specialKeys[keyInfo.Key]); + // everything else just gets sent right on through else serialPort.Write(Convert.ToString(keyInfo.KeyChar));