nodes: 0, module; 1, function_definition; 2, function_name:handle_keypress; 3, parameters; 4, block; 5, identifier:self; 6, identifier:k; 7, expression_statement; 8, if_statement; 9, comment:"""Last resort for keypresses."""; 10, comparison_operator:k == "esc"; 11, block; 12, elif_clause; 13, elif_clause; 14, elif_clause; 15, identifier:k; 16, string:"esc"; 17, expression_statement; 18, raise_statement; 19, comparison_operator:k == "delete"; 20, comment:# delete at end of line; 21, block; 22, comparison_operator:k == "backspace"; 23, comment:# backspace at beginning of line; 24, block; 25, comparison_operator:k == "enter"; 26, comment:# start new line; 27, block; 28, call; 29, call; 30, identifier:k; 31, string:"delete"; 32, expression_statement; 33, identifier:k; 34, string:"backspace"; 35, expression_statement; 36, identifier:k; 37, string:"enter"; 38, expression_statement; 39, comment:# move the cursor to the new line and reset pref_col; 40, expression_statement; 41, expression_statement; 42, attribute; 43, argument_list; 44, attribute; 45, argument_list; 46, call; 47, call; 48, call; 49, call; 50, call; 51, identifier:self; 52, identifier:save_file; 53, identifier:urwid; 54, identifier:ExitMainLoop; 55, attribute; 56, argument_list; 57, attribute; 58, argument_list; 59, attribute; 60, argument_list; 61, attribute; 62, argument_list; 63, attribute; 64, argument_list; 65, attribute; 66, identifier:combine_focus_with_next; 67, attribute; 68, identifier:combine_focus_with_prev; 69, attribute; 70, identifier:split_focus; 71, attribute; 72, identifier:keypress; 73, identifier:size; 74, string:"down"; 75, attribute; 76, identifier:keypress; 77, identifier:size; 78, string:"home"; 79, identifier:self; 80, identifier:walker; 81, identifier:self; 82, identifier:walker; 83, identifier:self; 84, identifier:walker; 85, identifier:self; 86, identifier:view; 87, identifier:self; 88, identifier:view
code: def handle_keypress(self, k):
          """Last resort for keypresses."""
          if k == "esc":
              self.save_file()
              raise urwid.ExitMainLoop()
          elif k == "delete":
              # delete at end of line
              self.walker.combine_focus_with_next()
          elif k == "backspace":
              # backspace at beginning of line
              self.walker.combine_focus_with_prev()
          elif k == "enter":
              # start new line
              self.walker.split_focus()
              # move the cursor to the new line and reset pref_col
              self.view.keypress(size, "down")
              self.view.keypress(size, "home")