Key Reading

closed account (38qG1hU5)
I know I just posted a newby post but I have another one. I have bought c++ books and searched the web but still can't figure out how to make the code read when a key is pressed to the activate the code in the statement. I know in c# its

if(input.getKeyDown(1)){
kshadhgaidgbkajgdyajib
}

Please help the new guy on the block.
What graphics/GUI library are you using? In SFML or Qt you should listen for the key down or key up events.

If you're trying to use the console, please read this first:
http://www.cplusplus.com/articles/G13hAqkS/
Last edited on
closed account (38qG1hU5)
@LB I'm not using GUI as I'm just trying to make a simple console game to further my experience and knowledge in c++. nothing huge just something to do.
Please read the article I linked. Making a console game will not further your experience, it will teach you things you will need to unlearn.
I disagree. The only difference in a console game is the display medium and handling input in the event loop properly -- which is actually a bit more difficult in a console app than a GUI one.

That said, I agree that it is worth your time to play around with SDL or SFML instead and go straight to a GUI game. They're tons easier and much more fun.
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/beginner/25477/

http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1048384015&id=1043284392
Last edited on
Um... why the hell have LB's and Duoas's posts been reported?
It's not just this tread. I think some nob is reporting *all* their posts.
Oh, look, they're doing it to me now.

Some people are easily amused, I guess.
Topic archived. No new replies allowed.