Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pygame key pressed once

# Outside loop
pressed = False

# Inside loop
if event.type == pygame.KEYDOWN:
	if event.key == pygame.K_a and not pressed: #K_a can be replaced by any key
		# Do something
		pressed = True
	elif event.key != pygame.K_a:
    	pressed = False
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pygame #key #pressed
ADD COMMENT
Topic
Name
1+8 =