Is there an inkey$-like command in c++?
Is there an inkey$-like command in c++?
What does the inkey$ command do, maybe I can help you.
none...
QBasic inkey$ holds any pressed keys like 'e' or 't'.
you would use it like this:
a$ = inkey$
<process on a$>
inkey holds the current keypress. What he needs to know is how to use the termios struct to get non-canonical <sp?> input. I don't have the code off the top of my head, someone else?
-----------------------
R. D. Nichols, Jr.
-Why do I have to go EVERYWHERE in this handbasket?
This code would set the terminal to raw mode.
code:--------------------------------------------------------------------------------
#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
struct termios o,
n;
if( tcgetattr( STDIN_FILENO, &o ) != 0 ) {
/* error handling */
}
n = o;
n.c_lflag &= ~( ICANON | ECHO );
n.c_cc[VMIN] = 1;
n.c_cc[VTIME] = 0;
if( tcsetattr( STDIN_FILENO, TCSANOW, &n ) != 0 ) {
/* error handling */
}
if( fcntl( STDIN_FILENO, F_SETFL, O_NONBLOCK ) == -1 ) {
/* error handling */
}
--------------------------------------------------------------------------------
Use this to make the terminal raw and nonblocking. And then you call getchar( ) at some arbitrary point - If it returns EOF, there was no key to read, otherwise it returns the key.
code:--------------------------------------------------------------------------------int ch;
ch = getchar( );
if( ch != EOF ) {
/* do something with ch */
}--------------------------------------------------------------------------------
And when you're done, restore the old terminal state:
code:--------------------------------------------------------------------------------tcsetattr( STDIN_FILENO, TCSANOW, &o );
Props to vVv, I stole his code.
-----------------------
R. D. Nichols, Jr.
-Why do I have to go EVERYWHERE in this handbasket?