def _on_key_press(self, event):
        """
        Called when a key was pressed.
        :param event: the event which fired this callback
        :type event: six.moves.tkinter.Event
        """
        # get the current position
        cp = self._get_cursor_position()  # TODO: check if this must be calculated before or after the keypress
        rng = self.selected_range
        replacement = event.char
        skip_should_change = False  # if true, skip should_change
        if self.debug:
            self.logger.debug("key {!r} pressed (symbol: {!r}; selected: {!r})".format(replacement, event.keysym, rng))
        
        if replacement in ("\r", "\r\n"):
            replacement = "\n"
        elif replacement == "\x08" and event.keysym != "h":
            # backspace (for some reason, same code as ctrl-h)
            replacement = u""
            if rng[0] == rng[1]:
                rng = (rng[0] - 1, rng[1])
        elif replacement == "\x7f":
            # del
            replacement = u""
            skip_should_change = True
            if rng[0] == rng[1]:
                rng = (rng[0], rng[1])
        elif replacement in self._keymapping:
            self.stash.user_action_proxy.vk_tapped(self._keymapping[replacement])
            return "break"
        
        if skip_should_change or self.stash.user_action_proxy.tv_responder.textview_should_change(None, rng, replacement):
            self.parent.tk.after(0, self._notify_change)
            #self.parent.tk.after(0, self._notify_cursor_move)
        else:
            # break event
            return "break"
        # TODO: the cursor probably moved

        Called when a key was pressed.
        :param event: the event which fired this callback
        :type event: six.moves.tkinter.Event
        
system/shui/tkui.py