Notices

Overclockers Forums > Software > Programming Tips and Tricks
Programming Tips and Tricks
Forum Jump

Keystrokes in C++

Post Reply New Thread Subscribe Search this Thread
 
 
Thread Tools
Old 04-22-02, 07:49 PM Thread Starter   #1
jokrswild
Member



Join Date: Jan 2002
Location: Ohio

 
Keystrokes in C++


Does anyone know how to register a keystroke in C++? I want to setup a loop, waiting for a keystroke, then depending on the keystroke do something. Kinda like the arrow keys in video games. You'll know what i'm talking about if you've programmed in TI-BASIC using the getkey command.
jokrswild is offline   QUOTE Thanks
Old 04-22-02, 09:51 PM   #2
KFB
Member

 
KFB's Avatar 

Join Date: Jun 2001
Location: CA

 
#include <iostream.h>
char x;
cin >> x; // or x = cin.get();
cout << x << endl;

try cplusplus.com for info.

__________________
"It's amazing what can be done with telephones and faxes..."
George W. Bush
KFB is offline   QUOTE Thanks
Old 04-22-02, 10:06 PM Thread Starter   #3
jokrswild
Member



Join Date: Jan 2002
Location: Ohio

 
but cin >> x reqires the user to hit enter after keying in whatever they want...

I'll try x=cin.get(), but i think it's the same thing. I want the keystroke to be registered (like an arrow key) without hitting enter....
jokrswild is offline   QUOTE Thanks
Old 04-22-02, 10:11 PM   #4
KFB
Member

 
KFB's Avatar 

Join Date: Jun 2001
Location: CA

 
oh. i didn't understand. sorry.

__________________
"It's amazing what can be done with telephones and faxes..."
George W. Bush
KFB is offline   QUOTE Thanks
Old 04-22-02, 10:43 PM Thread Starter   #5
jokrswild
Member



Join Date: Jan 2002
Location: Ohio

 
no need to be sorry! i probably worded it weird. lol
jokrswild is offline   QUOTE Thanks
Old 04-22-02, 11:38 PM   #6
Istari1
Member

 
Istari1's Avatar 

Join Date: Mar 2002
Location: Raleigh NC

 
I believe
x = getchar();

will just wait for a keystroke.

Josh
Istari1 is offline   QUOTE Thanks
Old 04-23-02, 02:56 PM   #7
Bmxpunk86pl
Member

 
Bmxpunk86pl's Avatar 

Join Date: Sep 2001
Location: CT/Poland

 
yea use the getchar() function
Bmxpunk86pl is offline   QUOTE Thanks

Post Reply New Thread Subscribe


Overclockers Forums > Software > Programming Tips and Tricks
Programming Tips and Tricks
Forum Jump

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Mobile Skin
All times are GMT -5. The time now is 12:38 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
You can add these icons by updating your profile information to include your Heatware ID, Benching Profile ID or your Folding/SETI profile ID. Edit your profile!
X

Welcome to Overclockers.com

Create your username to jump into the discussion!

New members like you have made this the best community on the Internet since 1998!


(4 digit year)

Why Join Us?

  • Share experience
  • Max out your hardware
  • Best forum members anywhere
  • Customized forum experience

Already a member?