PerformanceMeasuring.GameDebugTools.DebugCommandUI.IsKeyPressed C# (CSharp) Method

IsKeyPressed() private method

Pressing check with key repeating.
private IsKeyPressed ( Keys key, float dt ) : bool
key Keys
dt float
return bool
        bool IsKeyPressed(Keys key, float dt)
        {
            // Treat it as pressed if given key has not pressed in previous frame.
            if (prevKeyState.IsKeyUp(key))
            {
                keyRepeatTimer = keyRepeatStartDuration;
                pressedKey = key;
                return true;
            }

            // Handling key repeating if given key has pressed in previous frame.
            if (key == pressedKey)
            {
                keyRepeatTimer -= dt;
                if (keyRepeatTimer <= 0.0f)
                {
                    keyRepeatTimer += keyRepeatDuration;
                    return true;
                }
            }

            return false;
        }