[Mono-bugs] [Bug 81024][Wis] New - Console.ReadKey(true)

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sat Mar 3 15:21:21 EST 2007


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 barbosa at flexsolutions.com.br.

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

--- shadow/81024	2007-03-03 15:21:21.000000000 -0500
+++ shadow/81024.tmp.18729	2007-03-03 15:21:21.000000000 -0500
@@ -0,0 +1,99 @@
+Bug#: 81024
+Product: Mono: Runtime
+Version: 1.2
+OS: other
+OS Details: openSUSE
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: JIT
+AssignedTo: lupus at ximian.com                            
+ReportedBy: barbosa at flexsolutions.com.br               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Console.ReadKey(true)
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+Console.ReadKey(true) don't display key character.
+in windows show the character press.
+// This example demonstrates the Console.ReadKey() method
+using System;
+using System.Text;
+
+class Sample 
+{
+    public static void Main() 
+    {
+    ConsoleKeyInfo cki;
+//               0        1         2         3         4         5         6
+//               123456789012345678901234567890123456879012345678901234567890
+    String m1 = "This example discovers the console and modifier keys " +
+                "that you press.\n";
+    String m2 = "Press any combination of CTL, ALT, and SHIFT modifier
+keys, " +
+                "and a console key.\nPress the Escape (Esc) key to quit: ";
+    String m3 = "You pressed ";
+    String m4 = " (character '{0}').";
+    StringBuilder sb = new StringBuilder();   
+//
+// The Console.TreatControlCAsInput property prevents this example from
+// ending if you press CTL+C, however all other operating system keys and 
+// shortcuts, such as ALT+TAB or the Windows Logo key, are still in effect. 
+//
+    Console.TreatControlCAsInput = true;
+    Console.WriteLine(m1);
+    do 
+    {
+        Console.WriteLine(m2);
+        sb.Length = 0;
+        cki = Console.ReadKey(true);
+        sb.Append(m3);
+        if (cki.Modifiers != 0)
+            {
+            if ((cki.Modifiers & ConsoleModifiers.Alt) != 0)
+                sb.Append("ALT+");
+            if ((cki.Modifiers & ConsoleModifiers.Shift) != 0)
+                sb.Append("SHIFT+");
+            if ((cki.Modifiers & ConsoleModifiers.Control) != 0)
+                sb.Append("CTL+");
+            }
+        sb.Append(cki.Key.ToString());
+        sb.AppendFormat(m4, cki.KeyChar);
+        sb.AppendLine().AppendLine();
+        Console.WriteLine(sb.ToString());
+    } while (cki.Key != ConsoleKey.Escape);
+// Note: This example requires the Escape (Esc) key.
+    }
+}
+/*
+This example produces results similar to following text:
+
+This example discovers the console and modifier keys that you press.
+
+Press any combination of CTL, ALT, and SHIFT modifier keys, and a console key.
+Press the Escape (Esc) key to quit:
+You pressed A (character 'a').
+
+
+Press any combination of CTL, ALT, and SHIFT modifier keys, and a console key.
+Press the Escape (Esc) key to quit:
+You pressed SHIFT+A (character 'A').
+
+
+Press any combination of CTL, ALT, and SHIFT modifier keys, and a console key.
+Press the Escape (Esc) key to quit:
+You pressed ALT+SHIFT+CTL+A (character ' ').
+
+
+Press any combination of CTL, ALT, and SHIFT modifier keys, and a console key.
+Press the Escape (Esc) key to quit:
+You pressed Escape (character '?').
+*/
+
+
+Mono: 1.2.3 -> 2.0


More information about the mono-bugs mailing list