Checking every key has been released before changing screen colour
Hi, im working on project 4 and trying to make it so the screen dosent change colour till every key has been relesed. The problem I have is that the screen changes colour when I release a key, even if I have a second key pressed. How would you make it so the code checks to make sure no keys are pressed. Thanks
Re: Checking every key has been released before changing screen colour
One way is to require that the value remain zero for some minimum amount of time before acting on it. This can be done using a counter. Say you determine that the longest it will remain zero is the amount of time it takes to run through your loop that checks it 12 times. So you can set a counter up and any time you check the keyboard and it is not zero, you set the counter to zero. Then when you check the keyboard and it is zero, you increment the counter. If the counter is less that, say, 15, you do nothing more. But as soon as it hits 15 you now do whatever you want done when no keys are pressed.