in reply to Arrow keys with Curses.pm

You should call keypad(1) so you can compare returned key code to exported constants.
use strict; use Curses; my $screen = Curses->new(); # Enable keypad functionality keypad(1); while (my $key = getch()) { do { printw("KEY_LEFT\n"); refresh(); next } if $key eq KEY_L +EFT; do { printw("KEY_RIGHT\n"); refresh(); next } if $key eq KEY_R +IGHT; last; } exit 0;
BR

Replies are listed 'Best First'.
Re^2: Arrow keys with Curses.pm
by Pic (Scribe) on Oct 13, 2006 at 09:02 UTC
    D'oh. That's it of course.

    Now that you've said it I can even see where it's mentioned in the C language tutorial.

    Thanks a lot for your help.