public virtual bool keyPressed(KeyEvent keyEventRef)
        {
            if (m_bSettingsMode == true)
            {
                if (AdvancedMogreFramework.Singleton.m_pKeyboard.IsKeyDown(KeyCode.KC_S))
                {
                    SelectMenu pMenu = (SelectMenu)AdvancedMogreFramework.Singleton.m_pTrayMgr.getWidget("ChatModeSelMenu");
                    if (pMenu.getSelectionIndex() + 1 < (int)pMenu.getNumItems())
                    {
                        pMenu.selectItem((uint)pMenu.getSelectionIndex() + 1);
                    }
                }

                if (AdvancedMogreFramework.Singleton.m_pKeyboard.IsKeyDown(KeyCode.KC_W))
                {
                    SelectMenu pMenu = (SelectMenu)AdvancedMogreFramework.Singleton.m_pTrayMgr.getWidget("ChatModeSelMenu");
                    if (pMenu.getSelectionIndex() - 1 >= 0)
                    {
                        pMenu.selectItem((uint)pMenu.getSelectionIndex() - 1);
                    }
                }
            }

            if (AdvancedMogreFramework.Singleton.m_pKeyboard.IsKeyDown(KeyCode.KC_ESCAPE))
            {
                pushAppState(findByName("PauseState"));
                return(true);
            }

            if (AdvancedMogreFramework.Singleton.m_pKeyboard.IsKeyDown(KeyCode.KC_I))
            {
                if (m_pDetailsPanel.getTrayLocation() == TrayLocation.TL_NONE)
                {
                    AdvancedMogreFramework.Singleton.m_pTrayMgr.moveWidgetToTray(m_pDetailsPanel, TrayLocation.TL_TOPLEFT, 0);
                    m_pDetailsPanel.show();
                }
                else
                {
                    AdvancedMogreFramework.Singleton.m_pTrayMgr.removeWidgetFromTray(m_pDetailsPanel);
                    m_pDetailsPanel.hide();
                }
            }

            if (AdvancedMogreFramework.Singleton.m_pKeyboard.IsKeyDown(KeyCode.KC_TAB))
            {
                m_bSettingsMode = !m_bSettingsMode;
                return(true);
            }

            if (m_bSettingsMode && AdvancedMogreFramework.Singleton.m_pKeyboard.IsKeyDown(KeyCode.KC_RETURN) ||
                AdvancedMogreFramework.Singleton.m_pKeyboard.IsKeyDown(KeyCode.KC_NUMPADENTER))
            {
            }

            if (!m_bSettingsMode || (m_bSettingsMode && !AdvancedMogreFramework.Singleton.m_pKeyboard.IsKeyDown(KeyCode.KC_O)))
            {
                AdvancedMogreFramework.Singleton.keyPressed(keyEventRef);
            }

            return(true);
        }
        public bool keyPressed(KeyEvent evt)
        {
            if (!AdvancedMogreFramework.Singleton.m_pTrayMgr.isDialogVisible())
            {
                m_pChara.injectKeyDown(evt);
            }
            if (AdvancedMogreFramework.Singleton.m_pKeyboard.IsKeyDown(KeyCode.KC_ESCAPE))
            {
                pushAppState(findByName("PauseState"));
                return(true);
            }

            if (evt.key == KeyCode.KC_H || evt.key == KeyCode.KC_F1)       // toggle visibility of help dialog
            {
                if (!AdvancedMogreFramework.Singleton.m_pTrayMgr.isDialogVisible() && mInfo["Help"] != "")
                {
                    AdvancedMogreFramework.Singleton.m_pTrayMgr.showOkDialog("Help", mInfo["Help"]);
                }
                else
                {
                    AdvancedMogreFramework.Singleton.m_pTrayMgr.closeDialog();
                }
            }

            if (AdvancedMogreFramework.Singleton.m_pTrayMgr.isDialogVisible())
            {
                return(true);                          // don't process any more keys if dialog is up
            }
            if (evt.key == KeyCode.KC_F)               // toggle visibility of advanced frame stats
            {
                AdvancedMogreFramework.Singleton.m_pTrayMgr.toggleAdvancedFrameStats();
            }
            else if (evt.key == KeyCode.KC_G)               // toggle visibility of even rarer debugging details
            {
                if (m_pDetailsPanel.getTrayLocation() == TrayLocation.TL_NONE)
                {
                    AdvancedMogreFramework.Singleton.m_pTrayMgr.moveWidgetToTray(m_pDetailsPanel, TrayLocation.TL_TOPRIGHT, 0);
                    m_pDetailsPanel.show();
                }
                else
                {
                    AdvancedMogreFramework.Singleton.m_pTrayMgr.removeWidgetFromTray(m_pDetailsPanel);
                    m_pDetailsPanel.hide();
                }
            }
            else if (evt.key == KeyCode.KC_T)               // cycle polygon rendering mode
            {
                String newVal;
                TextureFilterOptions tfo;
                uint aniso;

                switch (Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(m_pDetailsPanel.getParamValue(9))))
                {
                case "B":
                    newVal = "Trilinear";
                    tfo    = TextureFilterOptions.TFO_TRILINEAR;
                    aniso  = 1;
                    break;

                case "T":
                    newVal = "Anisotropic";
                    tfo    = TextureFilterOptions.TFO_ANISOTROPIC;
                    aniso  = 8;
                    break;

                case "A":
                    newVal = "None";
                    tfo    = TextureFilterOptions.TFO_NONE;
                    aniso  = 1;
                    break;

                default:
                    newVal = "Bilinear";
                    tfo    = TextureFilterOptions.TFO_BILINEAR;
                    aniso  = 1;
                    break;
                }

                MaterialManager.Singleton.SetDefaultTextureFiltering(tfo);
                MaterialManager.Singleton.DefaultAnisotropy = aniso;
                m_pDetailsPanel.setParamValue(9, newVal);
            }
            else if (evt.key == KeyCode.KC_R)               // cycle polygon rendering mode
            {
                String      newVal;
                PolygonMode pm;

                switch (m_pCamera.PolygonMode)
                {
                case PolygonMode.PM_SOLID:
                    newVal = "Wireframe";
                    pm     = PolygonMode.PM_WIREFRAME;
                    break;

                case PolygonMode.PM_WIREFRAME:
                    newVal = "Points";
                    pm     = PolygonMode.PM_POINTS;
                    break;

                default:
                    newVal = "Solid";
                    pm     = PolygonMode.PM_SOLID;
                    break;
                }

                m_pCamera.PolygonMode = pm;
                m_pDetailsPanel.setParamValue(10, newVal);
            }
            else if (evt.key == KeyCode.KC_F5)              // refresh all textures
            {
                TextureManager.Singleton.ReloadAll();
            }
            else if (evt.key == KeyCode.KC_SYSRQ)               // take a screenshot
            {
                AdvancedMogreFramework.Singleton.m_pRenderWnd.WriteContentsToTimestampedFile("screenshot", ".png");
            }
            else if (evt.key == KeyCode.KC_X)
            {
                //spawn a new agent
                SinbadCharacterController agent = new SinbadCharacterController(this, physicsScene, m_pCamera, m_pChara.Position, agents.Count, false);
                agents.Add(agent);
            }

            m_pCameraMan.injectKeyDown(evt);
            return(true);
        }