docs: def keypress(self, win, char):
          """
           returns:
              1: get next char
              0: exit edit mode, string isvalid
             -1: cancel
          """
          if not self._focused:
              return 1
          if self.log is not None:
              self.log('char = {}\n'.format(char))
          if char in (curses.KEY_ENTER, ord('\n'), ord('\r')):
              """ ENTER """
              if self._has_history:
                  self._input_history.add_to_history(self._string)
              return 0
          elif char in (curses.KEY_EXIT, 27):
              self._edit_win.nodelay(True)
              char = self._edit_win.getch()
              self._log_file='/home/spiros/edit.log'
              self._log('   *** char = {}\n'.format(char))
              self._edit_win.nodelay(False)
              if char == -1:
                  """ ESCAPE """
                  self._string = ''
                  self._curs_pos = 0
                  return -1
              else:
                  return 1
          elif char in (curses.KEY_RIGHT, curses.ascii.ACK):
              """ KEY_RIGHT, Alt-F """
              self._curs_pos += 1
              if len(self._string) < self._curs_pos:
                  self._curs_pos = len(self._string)
          elif char in (curses.KEY_LEFT, ):
              """ KEY_LEFT """
              self._curs_pos -= 1
              if self._curs_pos < 0:
                  self._curs_pos = 0
          elif char in (curses.KEY_HOME, curses.ascii.SOH):
              """ KEY_HOME, ^A """
              self._curs_pos = 0
          elif char in (curses.KEY_END, curses.ascii.ENQ):
              """ KEY_END, ^E """
              self._curs_pos = len(self._string)
          elif char in (curses.KEY_DC, curses.ascii.EOT):
              """ DEL key, ^D """
              if self._curs_pos < len(self._string):
                  self._string = self._string[:self._curs_pos] + self._string[self._curs_pos+1:]
          elif char in (curses.KEY_BACKSPACE, curses.ascii.BS,127):
              """ KEY_BACKSPACE """
              if self._curs_pos > 0:
                  self._string = self._string[:self._curs_pos-1] + self._string[self._curs_pos:]
                  self._curs_pos -= 1
          elif char in (curses.KEY_UP, curses.ascii.DLE):
              """ KEY_UP, ^N """
              if self._key_up_function_handler is not None:
                  try:
                      self._key_up_function_handler()
                  except:
                      pass
              else:
                  if self._ungetch_unbound_keys:
                      curses.ungetch(char)
          elif char in (curses.KEY_DOWN, curses.ascii.SO):
              """ KEY_DOWN, ^P """
              if self._key_down_function_handler is not None:
                  try:
                      self._key_down_function_handler()
                  except:
                      pass
              else:
                  if self._ungetch_unbound_keys:
                      curses.ungetch(char)
          elif char in (curses.KEY_NPAGE, ):
              """ PgDn """
              if self._key_pgdown_function_handler is not None:
                  try:
                      self._key_pgdown_function_handler()
                  except:
                      pass
              else:
                  if self._ungetch_unbound_keys:
                      curses.ungetch(char)
          elif char in (curses.KEY_PPAGE, ):
              """ PgUp """
              if self._key_pgup_function_handler is not None:
                  try:
                      self._key_pgup_function_handler()
                  except:
                      pass
          elif char in (9, ):
              """ TAB """
              if self._key_tab_function_handler is not None:
                  try:
                      self._key_tab_function_handler()
                  except:
                      pass
              else:
                  if self._ungetch_unbound_keys:
                      curses.ungetch(char)
          elif char in (curses.KEY_BTAB, ):
              """ Shift-TAB """
              if self._key_stab_function_handler is not None:
                  try:
                      self._key_stab_function_handler()
                  except:
                      pass
              else:
                  if self._ungetch_unbound_keys:
                      curses.ungetch(char)
          elif char in (curses.ascii.VT, ):
              """ Ctrl-K - delete to end of line """
              self._string = self._string[:self._curs_pos]
          elif 0<= char <=31:
              pass
          else:
              if len(self._string) + 1 == self._max_width:
                  return 1
              if version_info < (3, 0):
                  if 32 <= char < 127:
                      # accept only ascii characters
                      if len(self._string) == self._curs_pos:
                          self._string += chr(char)
                          self._curs_pos += 1
                      else:
                          self._string = self._string[:self._curs_pos] + chr(char) + self._string[self._curs_pos:]
              else:
                  char = self._get_char(win, char)
                  if len(self._string) == self._curs_pos:
                      self._string += char
                      self._curs_pos += 1
                  else:
                      self._string = self._string[:self._curs_pos] + char + self._string[self._curs_pos:]
  
          self.refreshEditWindow()
          return 1