ConsoleKeyInfo Structure

 

Describes the console key that was pressed, including the character represented by the console key and the state of the SHIFT, ALT, and CTRL modifier keys.

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

[<Sealed>]
[<SerializableAttribute>]
type ConsoleKeyInfo = struct end

NameDescription
System_CAPS_pubmethodConsoleKeyInfo(Char, ConsoleKey, Boolean, Boolean, Boolean)

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

NameDescription
System_CAPS_pubpropertyKey

Gets the console key represented by the current ConsoleKeyInfo object.

System_CAPS_pubpropertyKeyChar

Gets the Unicode character represented by the current ConsoleKeyInfo object.

System_CAPS_pubpropertyModifiers

Gets a bitwise combination of System.ConsoleModifiers values that specifies one or more modifier keys pressed simultaneously with the console key.

NameDescription
System_CAPS_pubmethodEquals(ConsoleKeyInfo)

Gets a value indicating whether the specified ConsoleKeyInfo object is equal to the current ConsoleKeyInfo object.

System_CAPS_pubmethodEquals(Object)

Gets a value indicating whether the specified object is equal to the current ConsoleKeyInfo object.(Overrides ValueType.Equals(Object).)

System_CAPS_pubmethodGetHashCode()

Returns the hash code for the current ConsoleKeyInfo object.(Overrides ValueType.GetHashCode().)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns the fully qualified type name of this instance.(Inherited from ValueType.)

NameDescription
System_CAPS_puboperatorSystem_CAPS_staticEquality(ConsoleKeyInfo, ConsoleKeyInfo)

Indicates whether the specified ConsoleKeyInfo objects are equal.

System_CAPS_puboperatorSystem_CAPS_staticInequality(ConsoleKeyInfo, ConsoleKeyInfo)

Indicates whether the specified ConsoleKeyInfo objects are not equal.

The ConsoleKeyInfo 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 object 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 following example demonstrates using a ConsoleKeyInfo object in a read operation.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: