I'm working on my very first curses app, and now that I've decided to let the user move the cursor around with the arrow keys I've run into my first real roadblock.
I've got a main loop that runs like so:
while ( my $in = $main->getch () ) {
# Do stuff here.
}
Inside this loop, I'm trying to see if the user presses one of the arrow keys, and from the ncurses tutorial I've been reading (which is for C), it looks like the way to do it is either
$in == KEY_LEFT or
$in eq KEY_LEFT in the case of the left arrow key. However, this gracefully completely fails to work.
From my efforts at debugging, it looks like the program reads three characters each time one of the arrow keys is pressed.
Does anyone know how I can get this working the way I want to?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.