I'm trying to hack my own readline module ( and yes I am aware there are perfectly good readline modules on cpan allready ).

I use Term::ReadKey to get raw keyboard input and then simply lookup the ord value of a key in a hash table to decide which action to take. But some keys, like the arrows keys, do not result in a single char value when pressed, but output an escape sequence (I believe the keyboard hardware is doing this). All these sequences start with an "\e" but unfortunately this char is the same as outputted when one presses the 'esc' key. And I want to be able to bind an action to the 'esc' key, independent of any escape sequence.

My current sollution is to have a time-out of a few milli seconds after reading the 'esc' key to check whether there are keys following closely, and if there are rendering it as an escape sequence. This basicly works but causes a nasty bug when for instance one keeps pressed down an arrow key. Also it might fail when the typing speed is non-typical, like for instance in a remote terminal.

I realize this to be a design flaw but I can't think up any correct sollution. Does anyone have an idea how to solve this kind of problems ?
--
Jaap Karssenberg || Pardus (Larus)? <pardus@cpan.org>
>>>> Zoidberg: So many memories, so many strange fluids gushing out of patients' bodies.... <<<<

In reply to a ReadKey problem by Pardus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.