Process keyboard input

I am new to opengl and I would like some help on how to process keyboard input. I am using Win32 to run my opengl programs. In console application, the code bellow:

int x;
Please enter an integer.

allows the user to interact freely with the program without any predefined cases. I would like to know how to do the same thing in opengl.

Well, “cin” will stop your execution flow wait for input. There are two other slightly similar ways of doing it. Either you use the Win32 event-based model and capture an OnKeyPress-event, or whatever they’re named, or you run a console app. and do something like:

char ch;
ch = getch();

From what I understand, you can also use GLUT: Or, horror, DirectX’s DirectInput.

Thanks for your help, I will try to do what you’ve said.

GetAsynchKeyState() is much faster.