def keyboard_shortcut(self, win, scancode, *largs):
        modifiers = largs[-1]
        if scancode == 101 and modifiers == ['ctrl']:
            self.activated = not self.activated
            if self.activated:
                self.inspect_enabled = True
            return True

        elif scancode == 27:
            if self.inspect_enabled:
                self.inspect_enabled = False
                return True
            if self.activated:
                self.activated = False
                return True

        if not self.activated or not self.widget:
            return

        if scancode == 273:  # top
            self.widget = self.widget.parent

        elif scancode == 274:  # down
            filtered_children = [c for c in self.widget.children
                                 if not isinstance(c, Console)]
            if filtered_children:
                self.widget = filtered_children[0]

        elif scancode == 276:  # left
            parent = self.widget.parent
            filtered_children = [c for c in parent.children
                                 if not isinstance(c, Console)]
            index = filtered_children.index(self.widget)
            index = max(0, index - 1)
            self.widget = filtered_children[index]

        elif scancode == 275:  # right
            parent = self.widget.parent
            filtered_children = [c for c in parent.children
                                 if not isinstance(c, Console)]
            index = filtered_children.index(self.widget)
            index = min(len(filtered_children) - 1, index + 1)
            self.widget = filtered_children[index]
dataset/ETHPy150Open kivy/kivy/kivy/modules/console.py/Console.keyboard_shortcut/original