Does anyone know the ASCII Codes for the arrow keys? If it helps i'm using Borland on a Windows O/S, in console mode.
Does anyone know the ASCII Codes for the arrow keys? If it helps i'm using Borland on a Windows O/S, in console mode.
http://www.asciitable.com/
-Prelude
My best code is written with the delete key.
It is as follows
up arrow 0x48
down arrow 0x50
left arrow 0x4b
right arrow 0x4d
UP_KEY 1072
DOWN_KEY 1080
LEFT_KEY 1075
RIGHT_KEY 1077
Those are the key numbers you are looking for in borland
LB0: * Life once school is done
LB1: N <- WakeUp;
LB2: N <- C++_Code;
LB3: N >= Tired : N <- Sleep;
LB4: JMP*-3;
It doesn't sense the grey keys... What do I have to do?
Grey keys? I assume you mean the numpad..
I believe they're 100, 102, 104 and 106... I'm not sure in which order though.
Code:#include <iostream.h> #include <conio.h> int main() { char a = getch(); //press one of the arrow keys cout << "The ASCII value for the button you pressed is " << int(a); return 0; }
What about the main arrow keys?
Look at the program I just wrote. You can get the ASCII of any button. Just compile it.
It doesn't show it for the arrow keys next to the main part of the keyboard... The ones that don't use the num keys... any body?
Noone's responded in a while... Help!!!???
I Repeat question yes???
It doesn't show it for the arrow keys next to the main part of the keyboard... The ones that don't use the num keys... any body?
or
Does anyone know the code for the main arrow keys?
Here is what I use.
However Im using MSVC++ although it should still work for you.
note that when you press a function key, arrow key, or any other special key it will display twice because all of the non alphabetic keys send two hits to the input buffer.Code:#include <iostream.h> #include <conio.h> // for _kbhit and getch() int main() { char key; int iKey; bool endprog = false; do { if(_kbhit())//if a key is in the buffer { key = getch();//then get the key iKey = key; cout<<"key: "<<key<<" iKey: "<<iKey<<endl; if(key == 'Q' || key == 'q') endprog = true; } }while(!endprog); return 0; }
Also you might want to check your Borland documentation for allready defined constants. For example in MSVC++ the enter key is VK_RETURN.