System.Windows.Forms.CommandBar.PreProcessKeyDown C# (CSharp) Method

PreProcessKeyDown() private method

private PreProcessKeyDown ( Message &message ) : bool
message Message
return bool
        private bool PreProcessKeyDown(ref Message message)
        {
            Keys keyData = (Keys)(int) message.WParam | ModifierKeys;
            if (state == State.Hot)
            {
                int hotItem = this.GetHotItem();

                if (hotItem != -1)
                {
                    if (keyData == Keys.Left)
                    {
                        this.SetHotItem(this.GetPreviousItem(hotItem));
                        return true;
                    }

                    if (keyData == Keys.Right)
                    {
                        this.SetHotItem(this.GetNextItem(hotItem));
                        return true;
                    }

                    if ((keyData == Keys.Up) || (keyData == Keys.Down) || (keyData == Keys.Enter))
                    {
                        this.TrackDropDown(hotItem);
                        return true;
                    }
                }

                if (keyData == Keys.Escape)
                {
                    this.SetState(State.None, -1);
                    return true;
                }
            }

            bool alt = ((keyData & Keys.Alt) != 0);
            if ((state == State.Hot) || (alt))
            {
                Keys keyCode = keyData & Keys.KeyCode;
                char key = (char) (int) keyCode;
                if ((Char.IsDigit(key) || (Char.IsLetter(key))))
                {
                    // Process mnemonics.
                    if (this.PreProcessMnemonic(keyCode))
                        return true;

                    if ((state == State.Hot) && (!alt))
                    {
                        NativeMethods.MessageBeep(0);
                        return true;
                    }
                }
            }

            // return to default state if not handled
            if (state != State.None)
            {
                this.SetState(State.None, -1);
            }

            return false;
        }