• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Keyboard in C++

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.
Depending on how sophisticated you want to get you can do one of the following:
If it's a console app (i.e. black dos box style). Use getch()
If it's a windows app handle WM_KEYUP / WM_KEYDOWN
In either you can put in some DInput and get a lot of control over the keyboard.
 
ButcherUK said:
If it's a console app (i.e. black dos box style). Use getch()

What header is that in? There's getchar() in stdio.h that gives you the ASCII value for a key, but you have to press enter, and I need it instantaneously.

In either you can put in some DInput and get a lot of control over the keyboard.

Sorry, but what is that? I'm semi-new to C++ and don't know what that means :confused:
 
getch() is in conio.h, most compilers should have it but it's not guaranteed.
DInput is part of directx, it's significantly more complicated than getch, so not something for a beginner.
 
I don't know DirectX, but DInput looked like it would obviously be from DirectX.
 
Back