public static ConsoleKeyInfo ReadKey() { NativeConsole.INPUT_RECORD[] keyInfo = new NativeConsole.INPUT_RECORD[1]; //var test = Console.ReadKey(); uint nRead; while (NativeConsole.ReadConsoleInput(NativeConsole.GetStdHandle(NativeConsole.STD_INPUT_HANDLE), keyInfo, 1, out nRead) && nRead != 0) { //Debug.WriteLine("{0} {1} {2}", keyInfo[0].EventType, keyInfo[0].KeyEvent.bKeyDown, (int)keyInfo[0].KeyEvent.UnicodeChar); if (keyInfo[0].EventType == NativeConsole.InputEventType.Key && keyInfo[0].KeyEvent.bKeyDown && keyInfo[0].KeyEvent.UnicodeChar != 0) { var test1 = new ConsoleKeyInfo(keyInfo[0].KeyEvent.UnicodeChar, (ConsoleKey)keyInfo[0].KeyEvent.wVirtualKeyCode, (keyInfo[0].KeyEvent.dwControlKeyState & NativeConsole.ControlKeyStates.ShiftPressed) != 0, (keyInfo[0].KeyEvent.dwControlKeyState & (NativeConsole.ControlKeyStates.LeftAltPressed | NativeConsole.ControlKeyStates.RightAltPressed)) != 0, (keyInfo[0].KeyEvent.dwControlKeyState & (NativeConsole.ControlKeyStates.LeftCtrlPressed | NativeConsole.ControlKeyStates.RightAltPressed)) != 0 ); return(test1); } } throw new NotImplementedException(); }