i'm trying to create a little program with python and pygame but i have a problem.
I have the first model of Raspberry with 512 MB of RAM.
In my program the input from keyboard doens't work.
Code: Select all
import pygame
from pygame.locals import *
from sys import exit
#initializing variables
pygame.init()
screen=pygame.display.set_mode((640,480),0,24)
pygame.display.set_caption("Key Press Test")
f1=pygame.font.SysFont("comicsansms",24)
#main loop which displays the pressed keys on the screen
print("xx")
while True:
for i in pygame.event.get():
if i.type==QUIT:
exit()
a=100
screen.fill((255,255,255))
if pygame.key.get_focused():
press=pygame.key.get_pressed()
for i in range(0,len(press)):
if press[i]==1:
name=pygame.key.name(i)
print(name)
text=f1.render(name,True,(0,0,0))
screen.blit(text,(100,a))
a=a+100
pygame.display.update()The programm print on the screen only numlock but not the other keys.
On Windows this program run correctly.
Can you help me?
Thank you all