Click to See Complete Forum and Search --> : ncurses getch, and enter key


saai
10-15-2000, 01:20 PM
I am having trouble detecting when the enter key is pressed.
here is my current code:
nodelay();
nocbreak();
keypad(stdscr, TRUE);
int key = wgetch(stdscr);
if(key == KEY_ENTER
//do something
But, for some reason, the if statement is not succeeding. I have tried replacing KEY_ENTER with '\n', but with the same results. I would appreciate it if someone could help me out with this.
Thanks,
Saai

TheLinuxDuck
10-15-2000, 01:37 PM
Originally posted by saai:

int key = wgetch(stdscr);
if(key == KEY_ENTER
//do something
But, for some reason, the if statement is not succeeding.

You can try adding something like:
int key = wgetch(stdscr);
cout << "Key: " << key << newl;
if(key == KEY_ENTER
//do something
And just hit enter.. then you'll know the value that it's returning. http://www.linuxnewbie.org/ubb/smile.gif

------------------
TheLinuxDuck
Wait... that's a penguin?!?!?
:wq

Sterling
10-15-2000, 03:41 PM
Also, in my experience, a lot of input functions handle whitespace (\n, \t, and spaces) in some very odd ways.

------------------
-Sterling
-This post made with the Lizard! (http://www.mozilla.org)