/// <summary> /// Reads the key press. /// </summary> public bool ReadKeyPress() { if (Console.KeyAvailable) { string keyPressed = Console.ReadKey(false).KeyChar.ToString(); keyboardManager.HandleKeyPress(keyPressed); } return(true); }
/// <summary> /// Reads the key press. /// </summary> public bool ReadKeyPress() { if (Console.KeyAvailable) { // Clear the previous command. Since the amount of text printed by the previous // command is unknown, clear the everything below the current cursor position. // Note that the cursor is assumed to be already positioned within the designated // area for user input. int line = Console.CursorTop; ClearLine(line, (uint)(Console.WindowHeight - line)); Console.SetCursorPosition(0, line); // Handle the new command string keyPressed = Console.ReadKey(false).KeyChar.ToString(); keyboardManager.HandleKeyPress(keyPressed); if (keyPressed.Equals("q") || keyPressed.Equals("Q")) { return(false); } } return(true); }