private void HandleKey()
            {
                ReadPressedKeys();

                foreach (var key in m_newPressedKeys)
                {
                    if (m_oldPressedKeys.Contains(key))
                    {
                        continue;
                    }

                    if (!MyInput.Static.IsKeyValid((MyKeys)key))
                    {
                        ShowControlIsNotValidMessageBox();
                        break;
                    }

                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    MyControl ctrl = MyInput.Static.GetControl((MyKeys)key);
                    if (ctrl != null)
                    {
                        if (ctrl.Equals(m_controlBeingSet))
                        {
                            OverwriteAssignment(ctrl, key);
                            CloseScreen();
                        }
                        else
                        {
                            StringBuilder controlText = null;
                            MyControl.AppendName(ref controlText, (MyKeys)key);
                            ShowControlIsAlreadyAssigned(ctrl, controlText, () => OverwriteAssignment(ctrl, key));
                        }
                    }
                    else
                    {
                        m_controlBeingSet.SetControl(m_deviceType, (MyKeys)key);
                        CloseScreen();
                    }
                    break;
                }

                m_oldPressedKeys.Clear();
                MyUtils.Swap(ref m_oldPressedKeys, ref m_newPressedKeys);
            }
            private void HandleMouseButton()
            {
                MyInput.Static.GetListOfPressedMouseButtons(m_newPressedMouseButtons);

                //  don't assign buttons that were pressed when we arrived in the menu
                foreach (var button in m_newPressedMouseButtons)
                {
                    if (!m_oldPressedMouseButtons.Contains(button))
                    {
                        MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                        if (!MyInput.Static.IsMouseButtonValid(button))
                        {
                            ShowControlIsNotValidMessageBox();
                            break;
                        }

                        MyControl ctrl = MyInput.Static.GetControl(button);
                        if (ctrl != null)
                        {
                            if (ctrl.Equals(m_controlBeingSet))
                            {
                                OverwriteAssignment(ctrl, button);
                                CloseScreen();
                            }
                            else
                            {
                                StringBuilder controlText = null;
                                MyControl.AppendName(ref controlText, button);
                                ShowControlIsAlreadyAssigned(ctrl, controlText, () => OverwriteAssignment(ctrl, button));
                            }
                        }
                        else
                        {
                            m_controlBeingSet.SetControl(button);
                            CloseScreen();
                        }
                        break;
                    }
                }

                m_oldPressedMouseButtons.Clear();
                MyUtils.Swap(ref m_oldPressedMouseButtons, ref m_newPressedMouseButtons);
            }