On RaspberryPi (and RaspberryPi OS) I installed the keyboard module, the installation seems to be intact, but even the simplest functions don't work at all or behave erratically. I will give you two examples, though there are more. I execute my programs in the terminal using sudo.
Example A gives me no output at all, but shouldn't it actually? Same goes for the keyboard.send function.
import keyboard as kb
kb.write("hello")
example B gives me different output every time..., at some point stops working at all. Also, my idea was to block the output of "1" and only output the statement. With print functions it works fine btw.
import keyboard as kb
while True:
kb.wait("1")
kb.write("\nYou have pressed the number one!\n")
example C does do a playback of my input, but then it carries that input over to the next prompt, and takes them as a command as if enter were pressed.
import keyboard as kb
recorded = kb.record(until="esc")
kb.play(recorded)
In example D I simply want to allow for only digits to be entered by the user. It outputs my warning twice. Typing digits works fine, they get stored in a variable which gets printed out in the end. But what does ^[ mean here actually, why is it there at all? Again, all my pressed keys get carried over to the next prompt.
import keyboard as kb
keystroke = ""
digitstring = ""
while keystroke != "esc":
keystroke = kb.read_key()
if keystroke.isdigit() == True:
digitstring = digitstring + keystroke
continue
else:
print("\nOnly digits allowed!")
print(digitstring)
If anyone has any ideas or clues, please shoot! Thank you.