Search code examples
pythonuser-inputkeypressreplit

Is there a way to detect a key press in a python Replit?


I am making a chat app in Replit through Python. I have a while true loop that checks if a message has been posted and will check if you pressed the T key, and if so, pauses the loop to let you type and send your message. Because it is on replit, I cannot give root access.

I have tried using the keyboards module functions, like keyboard.is_pressed('t'), but that requires root access. I have looked through the docs there and have not found anything. I have also tried using the solutions in How to detect key presses?.


Solution

  • I used the getKey Module for it:

    from getkey import getkey
    key = getkey()
    if key == 't':