[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] [mac OS Sierra] key event not activated



Hello,

can you please try pygame 1.9.3 from pip?

I've seen this problem before with an old install... and it's working now. If you are using homebrew, it might mean that you also need to upgrade sdl libs.


cheers,


On Fri, Mar 3, 2017 at 10:03 AM, Mick O'shey <mickaushy@xxxxxxxxx> wrote:
Hello, 

When I ran the code below on mac os sierra, both of console window and pygame.display window kept focused. Then I typed something, letters went directly to console without going through the key events in the program. Escape key also didn't let me out of the program.
 
However people on irc (all on linux) couldn't reproduce the problem, assuming this could be one of the mac-specific problems.

I am using python 3.5.2(pyenv install) with pygame 1.9.2b6. Are there any way to avoid this problem?
(please excuse my English mistakes if any)

----------
import pygame

pygame.init()

pygame.display.set_mode((100, 100))
pygame.display.set_caption('keyname')

print('ready. ' + pygame.ver)
running = True
clock  = pygame.time.Clock()
while running:
    clock.tick(60)
    for e in pygame.event.get():
    # e = pygame.event.wait()
        if e.type == pygame.QUIT:
            running = False
        elif e.type == pygame.KEYDOWN:
            if e.key == pygame.K_ESCAPE:
                running = False
            else:
                keyname = pygame.key.name(e.key)
                print('key is pressed: ' + keyname)
                
        elif e.type == pygame.KEYUP:
            keyname = pygame.key.name(e.key)
            print('key is released: ' + keyname)
        
    # pygame.display.update()
                
pygame.quit()
----------