So, here is my final solution (based on the previous answer and using python-uinput). It uses the ability to type Unicode symbols by pressing Ctrl+Shift+U then typing the hex code of the symbol.
Here is the Python script I wrote for it:
import uinput, time
allKeys = [uinput.KEY_LEFTSHIFT, uinput.KEY_LEFTCTRL, uinput.KEY_SPACE, uinput.KEY_U,
uinput.KEY_A, uinput.KEY_B, uinput.KEY_C, uinput.KEY_D,
uinput.KEY_E, uinput.KEY_F, uinput.KEY_0, uinput.KEY_1,
uinput.KEY_2, uinput.KEY_3, uinput.KEY_4, uinput.KEY_5,
uinput.KEY_6, uinput.KEY_7, uinput.KEY_8, uinput.KEY_9]
device = uinput.Device(allKeys)
sleepInterval = 0.003
def printChar(charCode):
time.sleep(sleepInterval)
device.emit(uinput.KEY_LEFTSHIFT, 1);
device.emit(uinput.KEY_LEFTCTRL, 1);
device.emit_click(uinput.KEY_U);
device.emit(uinput.KEY_LEFTSHIFT, 0);
device.emit(uinput.KEY_LEFTCTRL, 0);
time.sleep(sleepInterval)
for symbol in charCode:
device.emit_click(uinput._chars_to_events(symbol)[0]);
time.sleep(sleepInterval)
device.emit_click(uinput.KEY_SPACE);
time.sleep(sleepInterval)
charString = "string that will be typed"
for char in charString:
printChar('{:04x}'.format(ord(char)))