My problem is in my code i use the Sleep function to prevent users from holding the key too long and toggling certain parts of the program from off too off again. However this still dosent fully solve the problem and forces my program to wait when it shouldn't have too.
Im pretty much trying to do what you see here but replace Sleep(150); with something that wont continue until the KEY_T is UP. Any suggestions?
1 2 3 4 5 6 7 8 9 10 11
if(GetAsyncKeyState(KEY_T)){
if(triggeron == true){
triggeron = false;
triggerstatus = "Disabled";
}
else{
triggeron = true;
triggerstatus = "Enabled";
}
Sleep(150); //Sleep so we dont hit the key again on accident
}
Well the actual time it takes to press the key isnt my main concern its only reading the key press 1 time so it dosent toggle on then off in the same press.
It cannot toggle off and then on in the same press. You should process keys as usual, and do as cire suggests and only activate the desired function after a certain time has passed since the "key is down" state is triggered.
You should be aware, however, that you need to be careful about what you are doing. It might annoy your users.