This documentation is archived and is not being maintained.

ConsoleKeyInfo Constructor

Initializes a new instance of the ConsoleKeyInfo structure using the specified character, console key, and modifier keys.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public ConsoleKeyInfo(
	char keyChar,
	ConsoleKey key,
	bool shift,
	bool alt,
	bool control


Type: System.Char
The Unicode character that corresponds to the key parameter.
Type: System.ConsoleKey
The console key that corresponds to the keyChar parameter.
Type: System.Boolean
true to indicate that a SHIFT key was pressed; otherwise, false.
Type: System.Boolean
true to indicate that an ALT key was pressed; otherwise, false.
Type: System.Boolean
true to indicate that a CTRL key was pressed; otherwise, false.


The numeric value of the key parameter is less than 0 or greater than 255.

This type is not intended to be created by users. Instead, it is returned to the user in response to calling the Console.ReadKey method.

The ConsoleKeyInfo type does not specify whether the left or right SHIFT, ALT, or CTRL modifier key was pressed.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.