def normal_mode_handle_events(self):
        """Event handling for the normal mode."""
        for event in SERVICES_NS.get_events():

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

            ### KEYUP

            elif event.type == KEYUP:

                ## if the escape key is released, turn
                ## the "running" flag off and the
                ## "cancel" flag on;
                ##
                ## this will cause the edition session
                ## to be ended (the widget loop will be
                ## exited in the "sort_sequence" method)

                if event.key == K_ESCAPE:

                    self.running = False
                    self.cancel = True

                ## if one of the enter keys are release,
                ## though, we set the running flag off,
                ## and leave the cancel flag untouched;
                ## since the cancelling flag is off by
                ## default, it means we are confirming
                ## the edition

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

            ### execute the respective methods for when
            ### the mouse left button is pressed or released

            ## pressed

            elif event.type == MOUSEBUTTONDOWN:

                if event.button == 1:
                    self.on_mouse_click(event)

            ## released

            elif event.type == MOUSEBUTTONUP:

                if event.button == 1:
                    self.on_mouse_release(event)
Event handling for the normal mode.
nodezator/our3rdlibs/sortingeditor/modes.py