I know they don't have standard ASCII values, but how do you check for them?
I am making a command prompt-type interface for a text-based RPG a friend and I are making, and I would like to be able to use the arrow keys to navigate in menus.
I am using getch(); in a do-while loop. The exiting condition of the loop is the user hits ENTER. This loop just keeps putting chars (gotten from getch() ) into a char array, with 0D hex or '\n' being the char that the loop stops on. Just a real simple loop. I included the following line into my developmental program to see what the values are of the keys that you press:
printf("%c %d ", str[num], str[num]);
and when the UP arrow key is pressed, this line displays " 0 H 72", with " 0 H" being the value of the UP arrow key. This apparently doesn't look like it will fit into a char, so how would I code for it? Because I wrote a function that displayed the length of the string passed to it and it said the string length was 0 characters long. It looks like the UP arrow key has the value of 72, but this is incorrect, because capital h has this decimal value, which leads me to believe that there are possibly NULL characters in the " 0 H", because my function that returns the length of the string counts '\0' (or NULL) as the end of the string. At face value, this looks like the "string" is 4 characters long.
But if the first 'char' in it is not a space, and instead, actually a NULL character, then it would return 0 characters long just like it is doing.
So what do you recommend me doing to check to see if the user hits an arrow key? I would like it to work just like the command prompt in DOS or Windows...when the user hits left or right, it takes them left or right one character in the text they have entered on the line. And when they hit up or down, it takes them up or down one command in their command history.
Thanks, :)
Diode