-2

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.

RobertBaron
  • 2,817
  • 1
  • 12
  • 19
Hakan Demir
  • 307
  • 2
  • 4
  • 12

1 Answers1

0

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.

RobertBaron
  • 2,817
  • 1
  • 12
  • 19