How to create a Flip Flop function in C++

Basically, I want the same key to toggle on and toggle off a function (in my case, I want a CTRL key to toggle Running on and off - so I don’t need to hold the key)

I have everything setup I just need to somehow get the CTRL to be a toggle key for Running function.

Thanks in advance!

void ToggleRunning()
{
bRunning = !bRunning;
}

1 Like

I’ll write it on simple C++. The idea is having a boolean changing its value in every execution of the loop.

	bool choseA = true;
	
	while(1){
		if(choseA){
			// code
			choseA = false;
		} else {
			// code
			choseA = true;
		}
	}
8 Likes