Exemple #1
0
        private void KeyboardEvents()
        {
            foreach (Keys key in KeyboardButtons)
            {
                //Checks whether key is currently pressed down
                if (CurrKS.IsKeyDown(key))
                {
                    if (KeyDown != null)
                    {
                        KeyDown(this, new KeyboardEvents(key, CurrKS, PrevKS));
                    }
                }

                //Checks whether key was released
                if (PrevKS.IsKeyDown(key) && CurrKS.IsKeyUp(key))
                {
                    if (KeyUp != null)
                    {
                        KeyUp(this, new KeyboardEvents(key, CurrKS, PrevKS));
                    }
                }

                //Checks whether key was pressed
                if (PrevKS.IsKeyUp(key) && CurrKS.IsKeyDown(key))
                {
                    if (KeyPressed != null)
                    {
                        KeyPressed(this, new KeyboardEvents(key, CurrKS, PrevKS));
                    }
                }
            }
        }
Exemple #2
0
 protected bool IsKeyDownUp(Keys key)
 {
     if (PrevKS.IsKeyDown(key) && CurrentKS.IsKeyUp(key))
     {
         return(true);
     }
     return(false);
 }