Original Post
How can I get input that distinguishes between every key on the keyboard? The GetAsyncKeyState function, which takes a virtual key code, seems to be a bit too helpful, in that it maps both enters to the same virtual key and, if the numlock is off, all of the special features under the numpad numbers get mapped to their corrispondents in the middle. This is very bad for mapping game controls. Here's a quick and dirty program that demonstrates what I mean:
#include <windows.h>
#include <cstdio>
int main ( )
{
COORD zero;
zero.X = 0;
zero.Y = 0;
while ( true )
{
SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), zero );
for ( unsigned int i = 0; i < 256; i++ )
{
SetConsoleTextAttribute ( GetStdHandle ( STD_OUTPUT_HANDLE ), BACKGROUND_BLUE | ( ( GetAsyncKeyState ( i ) & 0x80000000 ) ? BACKGROUND_INTENSITY : 0 ) );
printf ( "%X", i%16 );
if ( i%16 == 15 )
{
printf ( "\n" );
}
}
}
return 0;
}
[Edit by Oluseyi: Because horizontal scrolling is just wrong.]
please help
[edited by - Oluseyi on April 13, 2004 7:36:27 PM]