Hi fam!
I want to make a manual counter shell app in C++.
I want to increase/decrease an integer, by the use of the up and down arrow keys.
So far, I have gotten code that detects when the arrow keys are pressed and, which (when pressed) outputs a message to the shell. (screenshot 1. example has 4 upstrokes then 1 downstroke)
I want to output:
1 2 3 4 3
(4 upstrokes then 1 downstroke)
How would I go about this?
Here is the code I have so far (press up or down keys):
#include <conio.h>
#include
using namespace std;
#define KEY_UP 72
#define KEY_DOWN 80
int main()
{
int c = 0;
while(1)
{
c = 0;
switch((c=getch())) {
case KEY_UP:
cout << 1 << " ";
break;
case KEY_DOWN:
cout << -1 << " ";
break;
}
}
return 0;
}
Thanks
Dave