Beispiel #1
0
        public static bool WasButtonPressed(Keys key)
        {
            bool pressed = false;

            if (CurrentKeyState.IsKeyUp(key) && PreviousKeyState.IsKeyDown(key))
            {
                pressed = true;
            }
            return(pressed);
        }
        // Returns false if all keys were previously used or are not relesead
        public static bool AnyKeysReleased(params Keys[] keys)
        {
            if (keys.All(k => BlockList.Contains(k)))
            {
                return(false);
            }

            return(keys.Any(k =>
            {
                if (!KeyState.IsKeyUp(k) || !PreviousKeyState.IsKeyDown(k))
                {
                    return false;
                }

                BlockList.Add(k);
                return true;
            }));
        }
Beispiel #3
0
        public override void Update(GameTime gameTime)
        {
            if (!ShouldUpdate())
            {
                return;
            }

            if ((Keyboard.GetState().IsKeyDown(Keys.RightShift) && PreviousKeyState.IsKeyUp(Keys.RightShift)) ||
                (Keyboard.GetState().IsKeyDown(Keys.LeftShift) && PreviousKeyState.IsKeyUp(Keys.LeftShift)) ||
                (Keyboard.GetState().IsKeyUp(Keys.RightShift) && PreviousKeyState.IsKeyDown(Keys.RightShift)) ||
                (Keyboard.GetState().IsKeyUp(Keys.LeftShift) && PreviousKeyState.IsKeyDown(Keys.LeftShift)))
            {
                _swapFunctionKeySourceRectangles();
            }

            if (_lastScrollOffset != _scroll.ScrollOffset)
            {
                UpdateIconsForScroll();
            }

            base.Update(gameTime);
        }
Beispiel #4
0
 static bool IsKeyReleased(QKeyStates keyState)
 {
     return(CurrentKeyState.IsKeyUp((Keys)keyState) && PreviousKeyState.IsKeyDown((Keys)keyState));
 }
Beispiel #5
0
 public bool KeyReleased(Keys key)
 {
     return(CurrentKeyState.IsKeyUp(key) && PreviousKeyState.IsKeyDown(key));
 }
Beispiel #6
0
 public static bool IsKeyPreviouslyDown(Keys key)
 {
     return(PreviousKeyState.IsKeyDown(key));
 }