def vk_tapped(self, vk):
        """
        Called when a key was pressed
        :param vk: the pressed key
        :type vk: int
        """
        if self.debug:
            self.logger.debug("vk_tapped({vk})".format(vk=vk))
        if vk == K_TAB:  # Tab completion
            rng = self.terminal.selected_range
            # Valid cursor positions are only when non-selection and after the modifiable position
            if rng[0] == rng[1] and rng[0] >= self.stash.main_screen.x_modifiable:
                self.stash.mini_buffer.feed(rng, '\t')

        elif vk == K_HIST:
            self.history_present(self.stash.runtime.history)

        elif vk == K_HUP:
            self.stash.runtime.history.up()

        elif vk == K_HDN:
            self.stash.runtime.history.down()
        
        elif vk == K_LEFT:
            self.stash.mini_buffer.set_cursor(-1, whence=1)
        
        elif vk == K_RIGHT:
            self.stash.mini_buffer.set_cursor(1, whence=1)

        elif vk == K_CD:
            if self.stash.runtime.child_thread:
                self.stash.mini_buffer.feed(self.stash.mini_buffer.RANGE_BUFFER_END, '\0')

        elif vk == K_CC:
            if not self.stash.runtime.child_thread:
                self.stash.write_message('no thread to terminate\n')
                self.stash.io.write(self.stash.runtime.get_prompt())

            else:  # ctrl-c terminates the entire stack of threads
                self.stash.runtime.child_thread.kill()  # this recursively kill any nested child threads
                time.sleep(0.5)  # wait a moment for the thread to terminate

        elif vk == K_CZ:
            self.stash.runtime.push_to_background()

        elif vk == K_KB:
            if self.terminal.is_editing:
                self.terminal.end_editing()
            else:
                self.terminal.begin_editing()

        elif vk == K_CU:
            self.stash.mini_buffer.feed(self.stash.mini_buffer.RANGE_MODIFIABLE_CHARS, '')

        Called when a key was pressed
        :param vk: the pressed key
        :type vk: int
        
system/shui/base.py