Would anyone happen to know the ascii code in octal for the up, down, left and right keys?
Would anyone happen to know the ascii code in octal for the up, down, left and right keys?
They don't have single byte ASCII references as far as I remember.
but you can use this:
came from hereCode:#include <stdio.h> #include <limits.h> #include <stdlib.h> #include <windows.h> int main ( void ) { short esc = 0; while ( !esc ) { esc = GetAsyncKeyState ( VK_ESCAPE ); if ( GetAsyncKeyState ( VK_UP ) & SHRT_MAX ) puts ( "Up arrow is pressed" ); else if ( GetAsyncKeyState ( VK_DOWN ) & SHRT_MAX ) puts ( "Down arrow is pressed" ); else if ( GetAsyncKeyState ( VK_LEFT ) & SHRT_MAX ) puts ( "Left arrow is pressed" ); else if ( GetAsyncKeyState ( VK_RIGHT ) & SHRT_MAX ) puts ( "Right arrow is pressed" ); } return EXIT_SUCCESS; }
That way you don't have to remember them
ok, Thx man
would there be anyway to find out its code in a program?
like
and maby converting back to ascii?Code:char a = getch(); string thing=((oct)a); cout<<thing;
Last edited by Whizza; 05-24-2006 at 03:17 AM.
Here is a short program that will tell you the value of the keys. When you run it press all the keys you want to find out their ascii values. Special keys return the same value as other ascii keys, so I make special keys negative to distinguish the difference. Other programmers sometimes add 255 instead of making them negative.
Code:#include <conio.h> #include <iostream> using namespace std; #define ESC 27 int main() { int c = 0; while( c != ESC) { c = getch(); if(c == 0 || c == 224) c = -getch(); cout << c << endl; } return 0; }