def handle_events(self):
        """Iterate over event queue processing events."""
        for event in SERVICES_NS.get_events():

            if event.type == QUIT:

                ### disable text editing events
                stop_text_input()

                ### raise app quitting exception
                raise QuitAppException

            ### if text is input, add it

            elif event.type == TEXTINPUT:
                self.cursor.add_text(event.text)

            elif event.type == KEYUP:

                ### exiting the widget by either pressing
                ### escape or enter/numpad enter resumes
                ### the edition

                if event.key in (K_ESCAPE, K_RETURN, K_KP_ENTER):
                    self.resume_editing()

            elif event.type == KEYDOWN:

                ### ignore keys below

                if event.key in (K_ESCAPE, K_RETURN, K_KP_ENTER):
                    pass

                ### move cursor

                elif event.key == K_LEFT:
                    self.cursor.go_left()

                elif event.key == K_RIGHT:
                    self.cursor.go_right()

                ### snap cursor to different edges of
                ### line

                elif event.key == K_HOME:
                    self.cursor.go_to_beginning()

                elif event.key == K_END:
                    self.cursor.go_to_end()

                ### remove characters

                elif event.key == K_BACKSPACE:
                    self.cursor.delete_previous()

                elif event.key == K_DELETE:
                    self.cursor.delete_under()

                ### responses to keydown events when the
                ### control key is pressed

                elif event.mod & KMOD_CTRL:

                    ### edit entry text in text editor

                    if event.key == K_t:
                        self.edit_on_text_editor()

                    ### in all other scenarios, the event
                    ### must be ignored, since the
                    ### combination of ctrl key and other
                    ### keys doesn't produce characters
                    ### of our interest (only strings like
                    ### '\x08', etc.)
                    else:
                        pass

            ### releasing either the left or right button
            ### of the mouse out of the widget boundaries
            ### resumes the edition

            elif event.type == MOUSEBUTTONUP:

                if event.button in (1, 3):

                    if not self.rect.collidepoint(event.pos):
                        self.resume_editing()

            ### if window is resized, set handle_input
            ### to a new callable that keeps handling
            ### events and at the same time watches out
            ### for movement of the widget

            elif event.type == WINDOW_RESIZE_EVENT_TYPE:
                self.handle_input = self.watch_out_for_movement
Iterate over event queue processing events.
nodezator/widget/literalentry.py