Display event type in KeyLogger during key events
This commit is contained in:
@@ -22,6 +22,7 @@ class KeyLogger:
|
||||
# Handle SDL events
|
||||
events = sdl2.ext.get_events()
|
||||
for event in events:
|
||||
self.event = event.type
|
||||
if event.type == sdl2.SDL_KEYDOWN:
|
||||
keycode = event.key.keysym.sym
|
||||
# Log keycode to file
|
||||
@@ -34,12 +35,15 @@ class KeyLogger:
|
||||
self.running = False
|
||||
|
||||
# Update the window
|
||||
sdl2.ext.fill(self.window.get_surface(), sdl2.ext.Color(0, 0, 0))
|
||||
sdl2.ext.fill(self.window.get_surface(), sdl2.ext.Color(34, 0, 33))
|
||||
greeting = self.font.render("Press any key...", color=sdl2.ext.Color(255, 255, 255))
|
||||
sdl2.SDL_BlitSurface(greeting, None, self.window.get_surface(), None)
|
||||
if hasattr(self, 'message'):
|
||||
text_surface = self.font.render(self.message, color=sdl2.ext.Color(255, 255, 255))
|
||||
sdl2.SDL_BlitSurface(text_surface, None, self.window.get_surface(), sdl2.SDL_Rect(0, 30, 640, 480))
|
||||
if hasattr(self, 'event'):
|
||||
event_surface = self.font.render(f"Event: {self.event}", color=sdl2.ext.Color(255, 255, 255))
|
||||
sdl2.SDL_BlitSurface(event_surface, None, self.window.get_surface(), sdl2.SDL_Rect(0, 60, 640, 480))
|
||||
sdl2.SDL_UpdateWindowSurface(self.window.window)
|
||||
# Refresh the window
|
||||
|
||||
|
||||
Reference in New Issue
Block a user