Bug 323709 (MONO81024) - Console.ReadKey(true)
Summary: Console.ReadKey(true)
Status: RESOLVED MOVED
Alias: MONO81024
Product: Mono: Runtime
Classification: Mono
Component: JIT (show other bugs)
Version: 1.2
Hardware: Other Other
: P3 - Medium : Enhancement
Target Milestone: ---
Assignee: Jeff Stedfast
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-03 22:21 UTC by Juliano Barbosa
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:29:58 UTC


---- Reported by barbosa@flexsolutions.com.br 2007-03-03 15:21:21 MST ----

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



---- Additional Comments From gert.driesen@pandora.be 2007-04-18 10:19:21 MST ----

I assume this is a dup of https://bugzilla.novell.com/show_bug.cgi?id=MONO81050, right ?



---- Additional Comments From fejj@novell.com 2007-04-18 11:38:46 MST ----

I was about to say yes, and then I read the very top of his note...

he's saying that ReadKey(true) should echo the character, which goes
against what the docs say.

ReadKey(false) should echo, ReadKey(true) should not

Maybe I'm just mis-understanding what he is saying.

anyways, with the fix of https://bugzilla.novell.com/show_bug.cgi?id=MONO81050, our ReadKey() implementation
follows the specification.

*** This bug has been marked as a duplicate of https://bugzilla.novell.com/show_bug.cgi?id=MONO81050 ***


Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>openSUSE</cf_op_sys_details>
Unknown operating system other. Setting to default OS "Other".
This bug was marked DUPLICATE in the database it was moved from.
    Changing resolution to "MOVED"