/// <summary> /// Get keyboard input for the console. /// </summary> /// <param name="e"></param> private void GetConsoleInput(KeyEventArgs e) { var keyChar = KeyInterop.GetCharFromKey(e.KeyCode, (e.Modifiers & Keys.Shift) != 0); var capsLock = System.Windows.Forms.Control.IsKeyLocked(Keys.CapsLock); if (char.IsLetter(keyChar)) { if (capsLock || e.Shift) { keyChar = char.ToUpper(keyChar); } else { keyChar = char.ToLower(keyChar); } } else { switch (e.KeyCode) { case Keys.Back: if (_input.GetText().Length < 1) { _input.Hide(); _output.Hide(); _output.EnableFadeOut(); _consoleActive = false; } _input.RemoveLastChar(); return; case Keys.Up: _output.ScrollUp(); return; case Keys.Down: _output.ScrollDown(); return; case Keys.Enter: var text = _input.GetText(); _output.WriteLine(text); _output.EnableFadeOut(); _input.Hide(); _input.Clear(); _consoleActive = false; ExecuteCommandString(text); return; } } _input.AddChar(keyChar); }