“Pygame obtenga el código KeyPress” Código de respuesta

teclas de pygame presionadas

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

Pygame obtenga el código KeyPress

# 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

Respuestas similares a “Pygame obtenga el código KeyPress”

Preguntas similares a “Pygame obtenga el código KeyPress”

Más respuestas relacionadas con “Pygame obtenga el código KeyPress” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código