we have a project on school, coding a volleyball - match as console application. We should make input-output for teams and score etc, and bind keys to Team1-score+1, Team2-score-1 etc. That's fine. We use getch() to bind these keys. My problem: If you for example press R and R is Team1-score+1 and hold this key, it will continue adding the score+1, and we should stop that so you need to press R again if you want to add another point. I didn't find this solution anywhere! Can anyone give an example how to fix it? I am new on coding so I am inexperienced. Thanks for help guys! EDIT: I am using Windows 10, important part of my code:
while (true)
{
_kbhit();
char L = _getch();
if (L == 114)
{
score1 = score1 + 1;
}
else if (L == 99)
{
score1 = score1 - 1;
}
else if (L == 117)
{
score2 = score2 + 1;
}
else if (L == 110)
{
score2 = score2 - 1;
}
else if (L == 113)
{
L=="number" is the ascii-code for buttons r,u,c,n,q