Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Key repeat after input in pynput

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)

here is an example:

what I tried:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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())

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading