title: Curses Command Line Application in Python
body: <p>I'm writing a command line console application that receives input from user and interprets it as a command and performs the necessary action (like metasploit console). My application is already done and ready to go but my problem is I implemented it with <code>input()</code> function which does not handle arrow keys. If I mistype something and not notice it, I have to delete every character back to that typo and retype the rest of the command. I want to implement it in a way that would accept arrow keys to navigate around the characters. Is there anyone who knows how to do that?</p>
  <p>(As I specified above, I'm trying to find a way to do that with curses library. But any other library that can do what I need would be highly appreciated)</p>
  <p>Code example:</p>
  <pre><code>while True:
      command = input(&quot;command &gt;&quot;)
  
      if command == &quot;say_hello&quot;:
          print(&quot;Hello&quot;)
      elif command == &quot;exit&quot;:
          exit()
      else:
          print(&quot;Undefined command&quot;)
  </code></pre>