Python Forum
Why the heck is this not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why the heck is this not working
#2
1. pygame.key.get_pressed() get all key states. Either pygame.event.get() or pygame.event.pump() must be run before call this.

2. Your using key states in event loop.
while True:
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_w:
                print("w is pressed")
            elif event.key == pygame.K_s:
                print("s is pressed")
3. Using key states.
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pass

    pressed = pygame.key.get_pressed()
    if pressed[pygame.K_w]:
        print("w is pressed")
    
99 percent of computer problems exists between chair and keyboard.
Reply


Messages In This Thread
Why the heck is this not working - by YTPizzer - Feb-16-2019, 05:06 AM
RE: Why the heck is this not working - by Windspar - Feb-16-2019, 12:36 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020