I want to ask something about the keyboard input in Borland C++ v3.0. I wanted to ask how u get the input for arrowkeys..
i-e what is their ascii values..?
Printable View
I want to ask something about the keyboard input in Borland C++ v3.0. I wanted to ask how u get the input for arrowkeys..
i-e what is their ascii values..?
the arrow keys return a scan code that is hardware dependant, also they are extended bit encoded - the first digit they return is a zero and then they return the scan code. To find out what code they return on your system write a key detector that gets the key loops back after a zero and prints the integer value.
int check_key(); //begin checking function
{
int keypress; //holds the scan code of the keypress
keypress=getch();//get the keypress
if (keypress==0){check_key();}//check for extended key
else
cout<<keypress//print the scan code
int wait = getch();//wait for a keypress
}//end function
call this from main,
hope this helps
try:
int a;
a=getch();
cout << a;
//loop
do I have to include a special library class function header thingy? I try it in dev-c++4, and i get implicit declaration of getch()
I believe getch() is in conio.h.
#include <mingw_conio.h> if conio.h doesn't work