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 mouse clicking detection
- How can I make a sprite move when key is held down
- Add scrolling to a platformer in pygame
- Pygame unresponsive display [duplicate]
- Pyinstaller Unable to access Data Folder
- Is there any other way to load a resource like an image, sound, or font into Pygame? [closed]
- Does PyGame do 3d?
- Why does it say that module pygame has no init member?
- jumping too fast?
- How can one continuously generate and track several random objects with a time delay in pygame? [duplicate]
- What is the difference between .quit and .QUIT in pygame
- Pygame Display Position
- How to display text in pygame? [duplicate]
- Reset and restart pygame program doesn’t work
- What is causing this AttributeError?
- Pygame.movie missing [duplicate]
- How to move Sprite in Pygame
- Displaying unicode symbols using pygame
- Scale Everything On Pygame Display Surface
- How do I get the snake to grow and chain the movement of the snake’s body?
- Pygame error: ‘pygame’ has no attribute ‘init’
- Icons are not displayed properly with pygame
- How can I shoot a bullet with the space bar?
- How can I do a double jump in pygame?
- Installing Pygame for Mac OS X 10.6.8
- How do I focus light or how do I only draw certain circular parts of the window in pygame?
- How do I make the screen ignore the background color of some image?
- How to distinguish left click , right click mouse clicks in pygame? [duplicate]
- Setting a fixed FPS in Pygame, Python 3
- How to fix this DeprecationWarning