[Mono-bugs] [Bug 79711][Nor] Changed - Console.ReadKey () appears to not clear key

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Dec 20 06:53:21 EST 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by moritz.kroll at gmx.de.

http://bugzilla.ximian.com/show_bug.cgi?id=79711

--- shadow/79711	2006-11-24 17:30:57.000000000 -0500
+++ shadow/79711.tmp.1022	2006-12-20 06:53:21.000000000 -0500
@@ -69,6 +69,45 @@
 
 Additional Information:
 
 ------- Additional Comments From christopher_koch at transalta.com  2006-11-24 17:30 -------
 Also happens with 1.2.1 release of mono, and on a machine with XP SP2 
 and .Net Framework 2
+
+------- Additional Comments From Moritz.Kroll at gmx.de  2006-12-20 06:53 -------
+This still appears in Mono 1.2.2.1 on Windows XP.
+
+Here is a workaround I use for Mono on Windows:
+
+        public static ConsoleKeyInfo ReadKey(bool intercept)
+        {
+            while(true)
+            {
+                ConsoleKeyInfo key = Console.ReadKey(intercept);
+                switch(key.Key)
+                {
+                    case (ConsoleKey) 16:        // shift
+                    case (ConsoleKey) 17:        // control
+                    case (ConsoleKey) 18:        // alt
+                    case (ConsoleKey) 20:        // caps lock
+                    case (ConsoleKey) 30676:     // context menu
+                        Console.ReadKey(true);      // catch second 
+wrong key event
+                        break;
+                    case (ConsoleKey) 22:        // focus
+                        break;
+                    default:
+                        Console.ReadKey(true);      // catch wrong 
+key event
+                        return key;
+                }
+            }
+        }
+
+As this workaround implies, "keypresses" also become produced for 
+KeyUp and KeyDown of Shift, Control, Alt, Capslock, for opening and 
+closing the console context menu and for getting the focus.
+
+This does not appear with Mono 1.1.18 and Mono 1.2.2.1 on Linux, 
+though there the Insert and Delete produce an escape sequence with 3 
+keypresses instead of the correct Insert and Delete ConsoleKeys. The 
+other keys seem to work correctly.


More information about the mono-bugs mailing list