- ReadKey(): Obtains the next character or function key pressed by the user. The pressed key is displayed in the console window.
- ReadKey(true): Obtains the next character or function key pressed by the user, NOT display the pressed key in the console window.
- ReadKey(false): Obtains the next character or function key pressed by the user, display the pressed key in the console window.
Example:

// CLRConsole.cpp : main project file.
#include "stdafx.h"
using namespace System;
int main(array<System::String ^> ^args)
{
ConsoleKeyInfo keyPressed;
do{
Console::WriteLine(L"press and key, or Q to quit");
keyPressed = Console::ReadKey();
Console::WriteLine();
Console::WriteLine(keyPressed.KeyChar);
}while(keyPressed.KeyChar != 'Q' && keyPressed.KeyChar != 'q');
return 0;
}
No comments:
Post a Comment