title: Perl Term::ReadKey with Arrow Keys
body: <p>I'm using Term::ReadKey in ReadMode('cbreak') to read a single character and perform an action based on the input. This works fine for all other keys except the arrow keys. When the arrow keys are pressed, the action is performed 3 times and I understand this is because the arrow keys translate to '^[[A', etc... </p>
  
  <p>How do I translate the arrow keys into some arbitrary single value that the ReadKey can interpret?</p>
  
  <p>I tried the following code but it doesn't work:</p>
  
  <pre><code>use Term::ReadKey;
  
  ReadMode('cbreak');
  
  my $keystroke = '';
  
  while ($keystroke ne 'h') {
  
      print "Enter key: "; 
  
      #Read user keystroke 
      $keystroke = ReadKey(0);
  
      chomp($keystroke);
  
  
      if(ord($keystroke) == 27) {
           $keystroke = ('0');
      }
  }
  </code></pre>
  
  <p>Here's my code based on the suggestion:</p>
  
  <pre><code>use Term::RawInput;
  use strict;
  use warnings;
  
  my $keystroke = '';
  my $special = ''; 
  
  while(lc($keystroke) ne 'i' &amp;&amp; lc($keystroke) ne 't'){
  
      my $promptp = "Enter key: ";
  
      ($keystroke,$special) = rawInput($promptp, 1);
  
      if ($keystroke ne '') {
          print "You hit the normal '$keystroke' key\n";
      } else {
          print "You hit the special '$special' key\n";
      }
  
      chomp($keystroke);
  
      $keystroke = lc($keystroke);
  }
  
  if($keystroke eq 'i') {
      #Do something
  }
  
  if($keystroke eq 't') {
      #Do something
  }
  </code></pre>
  
  <p>Now, no matter what I press, I can't exit this loop</p>
  
  <p>Here's the output:</p>
  
  <pre><code>Enter key: 
  Enter key:
  Enter key: You hit the normal 't' key
  
  #Proceeds to function
  </code></pre>