I basically need something to take input from and print it or something else, but whatever I press it will repeat after I (close the program, read text input, etc)
what I tried:
I used the keyboard module instead of pynput module I used getch: it worked but not with keys like space,esc,up,down,etc
code:
from pynput.keyboard import Listener
kk=''
is_released=False
def getkey():
def on_release(k):
global is_released
global kk
kk=str(k)
is_released=True
return False
with Listener(on_release=on_release) as listener:
listener.join()
print('\b', end='')
return kk
while True:
print(getkey())
https://pynput.readthedocs.io/en/latest/keyboard.html#pynput.keyboard.Listener
Parameters:
suppress (bool) – Whether to suppress events. Setting this to True will prevent the input events from being passed to the rest of the system.