[Solved] Keypress window algorithm

For the past hour, I’ve been trying to create a way to make a window pop up on keypress and and disappear once pressed again. I’m using libGdx and here’s what I’ve been trying.

boolean windowOpen = false;
int windowY = 1000;

In my render method:

if(windowY < 1000)
      		batch.draw(window, 0, windowY);

Update method:

 if(Gdx.input.isKeyPressed(Keys.C) && !pressedC && windowY < 1000){
		   pressedC = true;
		   windowOpen = true; 
		   windowY = 1000;
		   
		   
	   }
	   
	   if(!Gdx.input.isKeyPressed(Keys.C) && pressedC){
		   pressedC = false;		   
	   }
	   
	   
	   
	   if(windowOpen)
		   windowY = 1000;
	   
	   
	   if(windowY >= 1 && !windowOpen) {
		   windowY-= 10;
	   }

I spent too much time and am loosing it :emo: , might as well make it disappear once Escape is pressed;