- 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:
![Obtain a single from Console using Console::ReadKey() Obtain a single from Console using Console::ReadKey()](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_Uisr3RHEazToNbMHMfCgqKGaOzUOcX74PLmgC9-g8jPAwMWrMA1Nb8TgmjouUAE91yn0NY3pT2G-8qPUWaf2NMw0vuX0Lnwhaa_Rc5sIPc9e7busKs5n_d_dwvxx0S7VC_6UMEGatGc/s400/ReadKey.png)
// 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