0

I am making a text-based game with frames, and my problem right now is that I have the code to check for keypresses

key = getkey.getkey()

But it seems like that command waits for you to press a key to continue with the code (that is, the command is blocking), and I would just like the game to continue updating, even if you don't press a key.

I was thinking of something like this:

import getkey

##Rest of my code

if key_pressed(any):
   key = getkey.getkey()

I'm using the getkey library, and I'm on the Replit webapp if that helps. I can't use something like msvcrt because I am on Linux.

3
  • 1
    getkey.getkey has a blocking kwarg. I'm not really sure how it works though; setting it to True seems to have made the function do literally nothing in my initial testing. Commented Jan 23 at 17:22
  • @Anerdw I got this quote from the PyPi page: API There is one primary method: getkey(blocking=True) so I'll check if it works. EDIT: It doesn't. Commented Jan 23 at 20:44
  • 1
    Sorry, my initial comment was wrong. That should be "setting blocking to False (not True) seems to make it do nothing." I would expect it to try to capture the currently pressed key and move on if there isn't one, but that doesn't seem to be the case. Commented Jan 23 at 20:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.