how can i do it, like how can i have it so it knows if have pushed like the right arrow instead of having them type r and enter it...
Printable View
how can i do it, like how can i have it so it knows if have pushed like the right arrow instead of having them type r and enter it...
getch() or virtual keys, read the FAQ.
Here's a windows method that's relatively simple:
-PreludeCode:#include <iostream>
#include <climits>
#include <windows.h>
int main()
{
short esc = 0;
while ( !esc ) {
esc = GetAsyncKeyState ( VK_ESCAPE );
if ( GetAsyncKeyState ( VK_UP ) & SHRT_MAX )
std::cout<<"Up arrow is pressed\n";
else if ( GetAsyncKeyState ( VK_DOWN ) & SHRT_MAX )
std::cout<<"Down arrow is pressed\n";
else if ( GetAsyncKeyState ( VK_LEFT ) & SHRT_MAX )
std::cout<<"Left arrow is pressed\n";
else if ( GetAsyncKeyState ( VK_RIGHT ) & SHRT_MAX )
std::cout<<"Right arrow is pressed\n";
std::cout.flush();
}
return EXIT_SUCCESS;
}
thanx prelude, thats exactly what i need :)