def handle_keyboard_input(self):
        """Act according to the keys' pressed state."""
        ### retrieve a list whose values represent the
        ### pressed state of the keys
        pressed_keys = SERVICES_NS.get_pressed_keys()

        ### retrieve the state of keys representing the
        ### left and right scrolling actions

        scroll_left = any(pressed_keys[i] for i in (K_LEFT, K_a))

        scroll_right = any(pressed_keys[i] for i in (K_RIGHT, K_d))

        ### trigger the corresponding actions according to
        ### the states of the keys retrieved in the previous
        ### step

        if scroll_left and not scroll_right:
            self.scroll_left()

        elif scroll_right and not scroll_left:
            self.scroll_right()
Act according to the keys' pressed state.
nodezator/our3rdlibs/sortingeditor/modes.py