Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #detect #key #pressed #pygame
ADD COMMENT
Topic
Name
3+5 =