TINI-8/core/input_handler.py

16 lines
385 B
Python
Raw Normal View History

# engine/input_handler.py
import pygame
class InputHandler:
def __init__(self):
self.keys = {}
def process_event(self, event):
if event.type == pygame.KEYDOWN:
self.keys[event.key] = True
elif event.type == pygame.KEYUP:
self.keys[event.key] = False
def is_key_pressed(self, key):
return self.keys.get(key, False)