Table of Contents

Method GetConsoleKeyInfoFromKeyCode

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

GetConsoleKeyInfoFromKeyCode(KeyCode)

Gets a ConsoleKeyInfo from a KeyCode.

public static ConsoleKeyInfo GetConsoleKeyInfoFromKeyCode(KeyCode key)

Parameters

key KeyCode

The key code to convert.

Returns

ConsoleKeyInfo

A ConsoleKeyInfo representing the key.

Remarks

This method is primarily used for test simulation via ToKeyInfo(Key). It produces a keyboard-layout-agnostic "best effort" ConsoleKeyInfo suitable for testing. For shifted characters (e.g., Shift+2), the character returned is US keyboard layout (Shift+2 = '@'). This is acceptable for test simulation but may not match the user's actual keyboard layout.