I wan't to make a program that logs keys. But is it possible to do this when the program is not focused? I only know how to do this when the program is focused.
Log keys when program is focused with pygame:
import pygame
from pygame.locals import *
import sys
pygame.init()
width, height = 300, 300
display = pygame.display.set_mode((width, height))
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == KEYDOWN:
print chr(event.key)