“Pygame Get Keypress Code” Réponses codées

touches pygame pressées

keys = pygame.key.get_pressed()
if keys[K_LEFT]:
    print("left")
Basti HD

Pygame Get Keypress Code

# importing pygame module
import pygame
 
# importing sys module
import sys
 
# initialising pygame
pygame.init()
 
# creating display
display = pygame.display.set_mode((300, 300))
 
# creating a running loop
while True:
       
    # creating a loop to check events that
    # are occuring
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
         
        # checking if keydown event happened or not
        if event.type == pygame.KEYDOWN:
           
            # if keydown event happened
            # than printing a string to output
            print("A key has been pressed")
Defeated Dormouse

Réponses similaires à “Pygame Get Keypress Code”

Questions similaires à “Pygame Get Keypress Code”

Plus de réponses similaires à “Pygame Get Keypress Code” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code