def OnKeyPressed(self, e):
        key = e.GetKeyCode()

        # Handle only UP and DOWN keys
        if key not in [wx.WXK_UP, wx.WXK_DOWN] or len(self.rows) == 0:
            e.Skip()
            return

        e.StopPropagation()

        # Get scrolling position
        start_col, start_row = self.GetViewStart()
        size = self.GetClientSize()
        height = size.GetHeight() / LINH

        if self.selection:
            # Process up/down keys
            current_row = self.selection[0]

            if key == wx.WXK_UP:
                next_row = max(current_row-1, 0)
            if key == wx.WXK_DOWN:
                next_row = min(current_row+1, len(self.rows)-1)

            # Process modifiers
            if e.ShiftDown() and self.allowMultiple:
                if self.selection in next_row:
                    self.selection.remove(current_row)
                else:
                    self.selection.insert(0, next_row)
            else:
                self.selection = [next_row]

        else:
            # Select topmost row of current view
            next_row = start_row
            if next_row < 0 or next_row > len(self.rows):
                return

            self.selection = [next_row]

        # Scroll selection if necessary
        if next_row < start_row:
            self.Scroll(start_col, next_row-1)
        elif next_row > start_row + height - 1:
            self.Scroll(start_col, next_row-height+2)

        # Emit selection event
        event = CommitListEvent(EVT_COMMITLIST_SELECT_type, self.GetId())
        event.SetCurrentRow(next_row)
        event.SetSelection(self.selection)
        self.ProcessEvent(event)
        self.OnSelectionChanged(next_row, self.selection)

        self.Refresh()
dataset/ETHPy150Open gyim/stupidgit/stupidgit_gui/CommitList.py/CommitList.OnKeyPressed/swapped operands of `in`