def keyboard_edition_control(self):
        """Process events in keyboard edition mode.

        Allows edition of the widget contents using the
        keyboard.
        """
        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 valid text is input, add it

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

            elif event.type == KEYUP:

                ### exiting the widget by either pressing
                ### escape, enter or numpad checks the
                ### need to revert back from expanded view
                ### and perform setups to resume the edition

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

                    self.check_expanded_view_reversal()
                    self.resume_editing()

            elif event.type == KEYDOWN:

                ### move cursor

                if 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:

                    if event.mod & KMOD_CTRL:
                        self.cursor.delete_previous_word()

                    else:
                        self.cursor.delete_previous()

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

                ### enable expanded view

                elif event.key == K_e and event.mod & KMOD_CTRL:
                    self.enable_expanded_view()


            ### releasing either the left or right button
            ### of the mouse out of the widget boundaries
            ### checks the need to revert back from
            ### expanded view and resumes the edition

            elif event.type == MOUSEBUTTONUP:

                if event.button in (1, 3):

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

                        self.check_expanded_view_reversal()
                        self.resume_editing()

            ## if window is resized, set the movement watch
            ## out routine

            elif event.type == WINDOW_RESIZE_EVENT_TYPE:
                self.movement_watch_out_routine = self.watch_out_for_movement

        self.movement_watch_out_routine()
Process events in keyboard edition mode.

        Allows edition of the widget contents using the
        keyboard.
        
nodezator/widget/intfloatentry/modes.py