#define OLC_PGE_APPLICATION #include "pixelGameEngine.h" //-------------------------------------------------------------------------------------------------- // class //-------------------------------------------------------------------------------------------------- class PressDetect : public olc::PixelGameEngine { public: PressDetect() { sAppName = "Double Press Down Detect"; } private: bool bothKeysPressed=false; public: bool OnUserCreate() override { return true; } //-------------------------------------------------------------------------------------------------- // Main Game Function //-------------------------------------------------------------------------------------------------- bool OnUserUpdate(float fElapsedTime) override { if (GetKey(olc::SHIFT).bHeld&&GetKey(olc::A).bHeld&&!bothKeysPressed) { bothKeysPressed=true; std::cout<<"Both Keys pressed\n"; } if (bothKeysPressed&&(GetKey(olc::SHIFT).bReleased||GetKey(olc::A).bReleased)) { bothKeysPressed=false; std::cout<<"Both Keys released\n"; } Clear(olc::VERY_DARK_BLUE); DrawRect({32,32},{32,32},(bothKeysPressed)?olc::YELLOW:olc::BLACK); return true; } }; int main() { PressDetect game; if (game.Construct(256, 240, 4, 4)) game.Start(); return 0; }