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

Re: [pygame] keyboard refresh

> pygame.key.set_repeat([500,30])
> and python says 
> Traceback (most recent call last):
>   File "jewel.py", line 67, in ?
>     pygame.key.set_repeat([500,30])
> TypeError: an integer is required

ah, another victim of ambiguous docutmentation. :]
what this notation means is that you pass either no
arguments or you pass two arguments. unfortunately
it looks a lot like you pass two arguments inside a list.
using brackets around argument descriptions is a common
way of referring to them as optional, but in python it
is definitely not as clear. perhaps there is a better

you can call the function like this...

pygame.key.set_repeat()  #disable key repeat events
pygame.key.set_repeat(500, 30)  #enable key repeats

> anyway what is the meaning of delay and interval, how do I 
> have to set them if i want a low refresh-rate (to get useful
> keyboard input for menues etc.)

every platform i've tried sets keyboard repeats with a method
like this. the two values are a time in milliseconds. the first
value (delay) is the amount of time from when the key is first
pressed until the first repeated KEYDOWN event is set. the
second value (interval) is the amount of time between each
repeated KEYDOWN event after that.

if your confused as to why you would need more than one value
think about people who want a very fast key repeat. if there
was only delay value, even a quick press of a key would give
you multiple keydown events (in fact, it can be impossible to
only generate a single keypress event). therefore you need 
that initial delay, so after the key is held down for awhile,
then the repeated keydown events start happening.

pygame mailing list