code: def _key_backspace(self, cursor_position):
          
          if self.has_selected_text():
              self.check_selection()
              self.remove_selected_text()
          elif self.current_prompt_pos == cursor_position:
              # Avoid deleting prompt
              return
          elif self.is_cursor_on_last_line():
              self.stdkey_backspace()
              if self.is_completion_widget_visible():
                  # Removing only last character because if there was a selection
                  # the completion widget would have been canceled
                  self.completion_text = self.completion_text[:-1]
docs: Action for Backspace key