python-3.xraspberry-piraspbiankeystrokeuinput

Generate keystrokes in Linux from Python3


I need to generate keystrokes in Linux (Raspbian) from Python3. Something like uinput but for Python3. I'd prefer not to use subprocess for this.

Easier to install (apt-get) the better as it will be used in a guide to show others.

Any ideas? Thomas


Solution

  • Found PyUserInput that works.

    https://github.com/SavinaRoja/PyUserInput/wiki/Installation https://github.com/SavinaRoja/PyUserInput

    sudo apt-get install python3-pip
    sudo pip-3.2 install python3-xlib
    sudo pip-3.2 install PyUserInput
    

    And the Python:

    from pykeyboard import PyKeyboard
    keyboard = PyKeyboard()
    keyboard.tap_key("a")