What is event.type TEXTINPUT used for? In the blender documentation I found the TEXTINPUT event type. I couldn't find any information about it. How it does it work? When can we use it? Is it only for the game engine or can we use it in common scripts?
This event is kind of a 'meta event' - you will never get an event of this type (Blender's event system never generates it).

It is used by keymap, as a kind of 'generic' event - it matches any real event that can be interpreted as a typed char. You can find its 'definition' at line 1530 and following of wm_event_system.c in Blender sources:

if (kmitype == KM_TEXTINPUT)
    if (winevent-&gt;val == KM_PRESS) {  /* prevent double clicks */
        /* NOT using ISTEXTINPUT anymore because (at least on Windows) some key codes above 255
         * could have printable ascii keys - BUG [#30479] */
        if (ISKEYBOARD(winevent-&gt;type) &amp;&amp; (winevent-&gt;ascii || winevent-&gt;utf8_buf[0])) return 1; 
    }


Translated in readable english, it means that any event that is a KM_PRESS (key press) from the keyboard and that generates a valid char (either ascii or unicode one) is considered as a TEXTINPUT event.