keypress?

E

enki

I am curios is there a way to do input with a single keypress in C++ or
using a standard library? Basically if I want a menu to pop up and you
choose 1-6 but you don't have to hit enter.

Is this possible?
 
P

Phlip

enki said:
I am curios is there a way to do input with a single keypress in C++ or
using a standard library? Basically if I want a menu to pop up and you
choose 1-6 but you don't have to hit enter.

Is this possible?

You may have a header file <conio.h>. If so, it will have a platform
specific getch() method, and maybe a getche().

Welcome to C++ - this question is platform specific. Not all C++
implementations have <conio.h>, because C++ needs a narrow definition to fit
in the widest number of appliances. So ask questions about conio.h on a
newsgroup that covers your specific compiler for best results.
 
S

Stephen Howe

I am curios is there a way to do input with a single keypress in C++ or
using a standard library? Basically if I want a menu to pop up and you
choose 1-6 but you don't have to hit enter.

Is this possible?

Yes, but ... NOT with standard C++ discussed here.

Standard C++ knows nothing about "clearing the screen", "keypresses",
"changing colours", "setting text cursors".
For any of those, your program has to call OS-specific functions. So you
need to find a newsgroup specific to programming your OS as they can't be
done with facilities offered by standard C++.

Stephen Howe
 
R

Rolf Magnus

enki said:
I am curios is there a way to do input with a single keypress in C++ or
using a standard library?

No. There are system specific libraries that offer this on many systems, but
the standard library doesn't.
 
E

enki

Thanks all I will see if I have the conio.h lib.
I just want to make my programs a little better.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top