def patterns_event_handling(self):
        """Event handling for the patterns mode.

        Grab and process pygame events (or similar objects).
        """
        for event in SERVICES_NS.get_events():

            ### raise a specific exception if the user
            ### tries to quit the app
            if event.type == QUIT:
                raise QuitAppException

            ### if user releases one of following keys,
            ### trigger exiting the colors viewer by
            ### setting the 'running' flag to False

            elif event.type == KEYUP:

                if event.key in (K_ESCAPE, K_RETURN, K_KP_ENTER):
                    self.running = False

            ### if the left mouse button is released,
            ### execute the corresponding mouse action
            ### method

            elif event.type == MOUSEBUTTONUP:

                if event.button == 1:
                    self.color_list_on_mouse_release(event)
Event handling for the patterns mode.

        Grab and process pygame events (or similar objects).
        
nodezator/colorsman/viewer/modes/patterns/main.py