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:

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