title: Using backspace with getch() in python curses
body: <p>I want the user to be able to type with each character, the way that getch() works. I also have echo() turned on because I want to print out each character that the user types. However, I also want the user to be able to hit backspace and have the key that he pressed before he hit backspace to be deleted from the screen, just like how backspace works in a text editor. How can I do this? I am using python 3.6 with the curses lib (obviously). If you want to see my code so far, here it is:</p>
  
  <pre><code>import curses
  
  # ----- INIT -----
  stdscr = curses.initscr()
  curses.cbreak()
  stdscr.keypad(1)
  
  # ----- PRINT -----
  text = "Hello world"
  stdscr.addstr(1, 0, text + "\n")
  stdscr.refresh()
  
  # ----- MAIN LOOP ------
  while 1:
      c = stdscr.getch()
      if c == ord('q'):
          break
  
  # ----- RESET TERMINAL -----
  curses.echo()
  curses.nocbreak()
  stdscr.keypad(1)
  curses.endwin()
  </code></pre>