dstar has asked for the wisdom of the Perl Monks concerning the following question:

(Updated; a pointer to Curses::Widgets fixed the problem I was having)
I don't seem to be able to get KEY_ENTER or a newline from getch(). My settings are:
my $mwh = new Curses; noecho(); halfdelay(1); $mwh->keypad(1); curs_set(0);
Am I doing something wrong?

Replies are listed 'Best First'.
Re: Curses problems
by Roger (Parson) on Nov 09, 2003 at 23:23 UTC
    It sounds like what you need what we call an unbuffered input. The getch() function inherits its behaviour from the underlying C curses library, which doesn't support such input.

    A fix is to 'mess' with the Unix terminal (assuming you are working on a Unix box). After you initialized the curses environment you have to put the terminal in the CBREAK mode, where all characters are returned immediatly after they are typed. This is done by calling $mwh->cbreak(); And then the terminal is ready to process the user input with getch, in unbuffered mode, including the Enter key.