[Python] Is there a way to getkey()/ getchar() asynchronously in python?

Discussão em 'Python' iniciado por Stack, Abril 23, 2025.

  1. Stack

    Stack Membro Participativo

    I need an asyncio compatible getkey() so I can

    async def stuff():
    await getkey()


    So when the coroutine stuff hits the await our loop stops the task, and continues on another one.

    I am new to coding, but there sure is such a thing somewhere?

    If not, is it possible to build such a coroutine? The getkey() could return the pressed key value in any form. But it should have cbreak and noecho on (don't wait for enter and don't print the pressed key).


    I know that this way of doing it seems unusual. Curses running in its own thread would be the right way to go. But I can use curses only for displaying. Also, I am really new to coding.. and I have no time to look into this threading thing:/ I just need my 100 lines to work fluently, really fast and also only once :!

    Continue reading...

Compartilhe esta Página