I'm trying to get pynput working on linux (ubuntu) but I just can't get it to work. I'm running my script on a terminal window on the desktop.
I've installed pynput but just it just won't detect my keystrokes. Here's the code that I'm using from my main script:
from pynput.keyboard import Key, Listener, Controller
from pynput import keyboard
def on_press():
print("key detected: " + str(key.char)))
listener = keyboard.Listener(on_press=on_press)
listener.start()
I've tried:
"sudo pip3 install web3"
"sudo pip3 install pynput"
"sudo pip3 install xlib"
"DISPLAY=:0.0 python3 -c 'import pynput'"
"xhost +"
And executing my script:
- "sudo python3 myscript.py"
- "python3 myscript.py"
But none of that seems to work regardless of running as root or not.
I do however get Xlib.xauth: warning, no xauthority details available, idk if that's causing the issue?
Any advice is appreciated. Cheers.