Table of Contents

Method ToString

Namespace
Terminal.Gui.Drivers
Assembly
Terminal.Gui.dll

ToString(ConsoleKeyInfo)

Returns a string representation of the ConsoleKeyInfo suitable for debugging and logging.

public static string ToString(this ConsoleKeyInfo consoleKeyInfo)

Parameters

consoleKeyInfo ConsoleKeyInfo

The ConsoleKeyInfo to convert to string.

Returns

string

A formatted string showing the key, character, and modifiers.

Remarks

Examples:

<ul><li><code>Key: A ('a')</code> - lowercase 'a' pressed</li><li><code>Key: A ('A'), Modifiers: Shift</code> - uppercase 'A' pressed</li><li><code>Key: A (\0), Modifiers: Control</code> - Ctrl+A (no printable char)</li><li><code>Key: Enter (0x000D)</code> - Enter key (carriage return)</li><li><code>Key: F5 (\0)</code> - F5 function key</li><li><code>Key: D2 ('@'), Modifiers: Shift</code> - Shift+2 on US keyboard</li><li><code>Key: None ('é')</code> - Accented character</li><li><code>Key: CursorUp (\0), Modifiers: Shift | Control</code> - Ctrl+Shift+Up Arrow</li></ul>