private bool OnKeyRepeat(ref KeyEventArg e)
        {
            KeyCode key = e.key;

            if (key >= KeyCode.A && key <= KeyCode.Z ||
                key >= KeyCode.D0 && key <= KeyCode.D9)
            {
                return OnKeyPressed(ref e);
            }

            if (key == KeyCode.Left ||
                key == KeyCode.Right ||
                key == KeyCode.Back ||
                key == KeyCode.Delete)
            {
                return OnKeyPressed(ref e);
            }

            if (e.IsCtrlPressed())
            {
                if (key == KeyCode.Up || key == KeyCode.Down)
                {
                    return OnKeyPressed(ref e);
                }
            }

            if (keyBindings.ContainsKey(key))
            {
                return OnKeyPressed(ref e);
            }

            return false;
        }
        private bool OnKeyPressed(ref KeyEventArg e)
        {
            KeyCode key = e.key;

            if (e.IsCtrlPressed())
            {
                if (key == KeyCode.Left)
                {
                    MoveCursorWordLeft();
                    return true;
                }

                if (key == KeyCode.Right)
                {
                    MoveCursorWordRight();
                    return true;
                }

                if (key == KeyCode.Up)
                {
                    ScrollUp();
                    return true;
                }

                if (key == KeyCode.Down)
                {
                    ScrollDown();
                    return true;
                }

                if (key == KeyCode.A)
                {
                    MoveCursorHome();
                    return true;
                }

                if (key == KeyCode.E)
                {
                    MoveCursorEnd();
                    return true;
                }
            }

            if (e.IsShiftPressed())
            {
                char bindShiftChr;
                if (keyShiftBindings.TryGetValue(key, out bindShiftChr))
                {
                    EnterChar(bindShiftChr);
                    return true;
                }
            }

            if (key >= KeyCode.A && key <= KeyCode.Z)
            {
                char chr = (char)key;
                if (!e.IsShiftPressed())
                {
                    chr = char.ToLower(chr);
                }

                EnterChar(chr);
                return true;
            }

            if (key >= KeyCode.D0 && key <= KeyCode.D9 || key == KeyCode.Space)
            {
                EnterChar((char)key);
                return true;
            }

            if (key == KeyCode.Left)
            {
                MoveCursorLeft();
                return true;
            }

            if (key == KeyCode.Right)
            {
                MoveCursorRight();
                return true;
            }

            if (key == KeyCode.Up)
            {
                PrevHistory();
                return true;
            }

            if (key == KeyCode.Down)
            {
                NextHistory();
                return true;
            }

            if (key == KeyCode.Back)
            {
                DeletePrevChar();
                return true;
            }

            if (key == KeyCode.Delete)
            {
                DeleteNextChar();
                return true;
            }

            if (key == KeyCode.Enter)
            {
                TryExecuteCommand();
                return true;
            }

            if (key == KeyCode.Tab)
            {
                DoAutoComplete();
                return true;
            }

            if (key == KeyCode.Home)
            {
                MoveCursorHome();
                return true;
            }

            if (key == KeyCode.End)
            {
                MoveCursorEnd();
                return true;
            }

            if (key == KeyCode.Escape)
            {
                Clear();
                return true;
            }

            char bindChr;
            if (keyBindings.TryGetValue(key, out bindChr))
            {
                EnterChar(bindChr);
                return true;
            }

            return false;
        }