Answers for "how to detect keys in pygame"

0

how to detect when a key is pressed in pygame

import pygame

keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
    x -= 1
if keys[pygame.K_RIGHT]:
	x += 1
Posted by: Guest on June-12-2021

Python Answers by Framework

Browse Popular Code Answers by Language