I wanted some code to get keyboard input and stumbled across getch(), to test it i wrote this code:
Code:
#include <cstdlib>
#include <iostream>
#include <conio.h>
using namespace std;
int main(int argc, char *argv[])
{
int y;
while (1)
{
y=getch();
cout << y << "\n";
}
}
when you run the program and press a key such as the arrow keys, it displays 2 numbers instead of one. The first number is always 224, and the second is unique to each key. I know getch() returns the ascii value, and the buttons that return 2 numbers don't have an ascii character equated to them. My question is how can you read the second of the two numbers in something like an "if" statement? For example sensing the arrow keys through getch().