Console.ReadKey Method (Boolean)
Obtains the next character or function key pressed by the user. The pressed key is optionally displayed in the console window.
Assembly: mscorlib (in mscorlib.dll)
[<HostProtectionAttribute(SecurityAction.LinkDemand, UI = true)>] static member ReadKey : intercept:bool -> ConsoleKeyInfo
- Type: System.Boolean
Determines whether to display the pressed key in the console window. true to not display the pressed key; otherwise, false.
Return ValueType: System.ConsoleKeyInfo
A ConsoleKeyInfo object that describes the ConsoleKey constant and Unicode character, if any, that correspond to the pressed console key. The ConsoleKeyInfo object also describes, in a bitwise combination of ConsoleModifiers values, whether one or more Shift, Alt, or Ctrl modifier keys was pressed simultaneously with the console key.
The ReadKey method waits, that is, blocks on the thread issuing the ReadKey method, until a character or function key is pressed. A character or function key can be pressed in combination with one or more Alt, Ctrl, or Shift modifier keys. However, pressing a modifier key by itself will not cause the ReadKey method to return.
If the intercept parameter is true, the pressed key is intercepted and not displayed in the console window; otherwise, the pressed key is displayed.
The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: UI. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.