[Python] Is there a way (in Python, specifically Replit) to detect key presses without them...

Discussão em 'Python' iniciado por Stack, Janeiro 17, 2025.

  1. Stack

    Stack Membro Participativo

    Basically what it says in the title. I'm making a python game in Replit and I need to get player input (specifically WASD and SPACE) without the characters being printed to the screen.

    First, I looked here and found this code:

    class keyboardDisable():

    def start(self):
    self.on = True

    def stop(self):
    self.on = False

    def __call__(self):
    while self.on:
    msvcrt.getwch()


    def __init__(self):
    self.on = False
    import msvcrt

    disable = keyboardDisable()
    disable.start()


    But I'm on a Chromebook, and I realized that this wouldn't work, because the library "msvcrt" is meant for Windows. I've heard of PyNput, and I'm doing some research on that.

    I think that mostly what I an looking for is a library that can disable the keyboard printing, because I just found a module called "keyboard" which can detect keypresses.

    Continue reading...

Compartilhe esta Página