• 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.

ButcherUK

Member
Joined
Nov 8, 2001
Location
York, UK
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.
 
OP
B

Barium56

Registered
Joined
Sep 26, 2001
Location
People's Republic of America
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:
 

ButcherUK

Member
Joined
Nov 8, 2001
Location
York, UK
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.
 

XWRed1

Senior Member
Joined
Oct 31, 2001
I don't know DirectX, but DInput looked like it would obviously be from DirectX.