You can use pygame.key.get_pressed to do that.
example:
while running:
keys = pygame.key.get_pressed() #checking pressed keys
if keys[pygame.K_UP]:
y1 -= 1
if keys[pygame.K_DOWN]:
y1 += 1
More Related Contents:
- pygame – How to display text with font & color?
- Sometimes the ball doesn’t bounce off the paddle in pong game
- How do I blit a PNG with some transparency onto a surface in Pygame?
- Embedding a Pygame window into a Tkinter or WxPython frame
- python pygame.camera.init() NO vidcapture
- Python – pygame error when executing exe file
- How do I make my player rotate towards mouse position?
- How to get if a key is pressed pygame [duplicate]
- Solving “DLL load failed: %1 is not a valid Win32 application.” for Pygame
- How can I make an Image with a transparent Backround in Pygame?
- How to set the pivot point (center of rotation) for pygame.transform.rotate()?
- Closing Pygame Window
- How to install PyGame on Python 3.4?
- Pygame: Is there any easy way to find the letter/number of ANY alphanumeric pressed?
- Moving forward after angle change. Pygame
- Saving the highscore for a game?
- problems with pygame controller support
- How to make image stay on screen in pygame?
- Python pygame not installing
- Any way to speed up Python and Pygame?
- How to move a no frame pygame windows when user click on it?
- How to move a no frame pygame windows when user clicks on it?
- Pygame make sprite walk in given rotation
- How to add pause mode to Python program
- how to center image inside a rect pygame
- PyGame rect.move movement not functioning properly
- Check collision between a image and a line
- Changing colour of a surface without overwriting transparency
- What is the difference between super() with arguments and without arguments?
- How do I change the volume of the sound or music in PyGame?