[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Repeating keypresses



> I tried to make keypresses repeat using the snippet:
> pygame.key.set_repeat ()

to be honest, i've not tested the key repeat much.
in pygame it is a simple function that just calls
SDL_EnableKeyRepeat(delay, interval);

i just spent some time playing with it. it seems to
be working well for me on windows.

i did just notice the pygame code wasn't checking the
result of this SDL call, so if an error was happening,
it wasn't being reported.

also, passing no arguments is supposed to 'disable the
repeat events'. i just tweaked the docs a little to 
be less confusing.

anyways, try out the attached script, maybe the simple
case will work?

#pass user events


import pygame
from pygame.locals import *



pygame.init()
screen = pygame.display.set_mode((100,100))

pygame.event.set_blocked(MOUSEMOTION)
pygame.key.set_repeat(500,50)


while 1:
    event = pygame.event.wait()
    print 'EVENT:', event
    if event.type == QUIT: break
    elif event.type == KEYDOWN and event.key == K_ESCAPE: break