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

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Oct 20 17:48:27 EDT 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 christopher_koch at transalta.com.

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

--- shadow/79711	2006-10-20 17:48:27.000000000 -0400
+++ shadow/79711.tmp.15203	2006-10-20 17:48:27.000000000 -0400
@@ -0,0 +1,70 @@
+Bug#: 79711
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: Win XP SP1 w/ .NET Framework 1.1 and mono 1.1.18 installed via installer
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: christopher_koch at transalta.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Console.ReadKey () appears to not clear key
+
+Please fill in this template when reporting a bug, unless you know what 
+you are doing.
+Description of Problem:
+
+When using ReadKey () to read a single keypress, it works, but a 
+subsequent call to ReadKey () reads the same keypress.  ie: each key 
+pressed causes 2 ReadKey calls to return with that key.  (Purely 
+speculation but perhaps both the KeyDown and KeyUp or KeyUp and KeyPressed 
+are both putting the key pressed into the buffer?)
+
+Steps to reproduce the problem:
+1. Put the following code into contest.cs:
+----------------------------------
+using System;
+
+namespace A
+{
+	public class B 
+	{
+		public static void Main ()
+		{
+			Console.WriteLine ("line1");
+			Console.WriteLine (Console.ReadKey ().Key);
+			Console.WriteLine ("line2");
+			Console.WriteLine (Console.ReadKey ().Key);
+			Console.WriteLine ("line3");
+			Console.WriteLine (Console.ReadKey ().Key);
+			Console.WriteLine ("line4");
+		}
+	}
+}
+----------------------------------
+2. Compile: gmcs contest.cs
+3. Run: mono contest.exe
+
+Actual Results:
+- Console displays "line1" and waits for input.
+- After any key is pressed (lets say "A"), console 
+displays "A", "line2", "A", "line3" and again waits for input
+- After any key is pressed (lets say "B"), console displays "B", "Line4"
+
+Expected Results:
+- Console displays "line1" and waits for input.
+- After any key is pressed (lets say "A"), console displays "A", "line2" 
+then waits for input
+- repeat previous line 2 more times
+
+How often does this happen? 
+
+Every time.
+
+Additional Information:


More information about the mono-bugs mailing list