I am on ncurses.I am working on a program that starts a timer when I press enter. I use this code:
while(( ch = wgetch(w)) != 'q' )
{
switch( ch ) {
...
case ENTER: /*timer is expected to start by a function*/
}
However, I need to hold down the Enter key to make the timer start. What I would like is to simply press the Enter key to start the timer. How can I solve this? I have the timer function. Thanks in advance.
I believe you need to set nodelay
to FALSE
and called cbreak()
so that wgetch()
blocks, wait for the next character typed, and return it.
nodelay(w, FALSE);
cbreak();
It's been awhile since I used ncurses, but if I recall correctly, that should do it. Let me know.