I am trying to fade a grating continuously while a key is held down.
I have the following in Each Frame:
key = event.getKeys()
if key:
print(key)
print(c)
c = c - 0.01
grating.contrast = c
print(grating.contrast)
However, only one keypress is registered, nothing further happens while the key is held down.
Could I ask for some help understanding this? I thought that getKeys would check asychronously whether a key was down. However, it doesn’t register another keypress until I release the key and press it again.
I also tried:
key = kb.getKeys(['right'], waitRelease=False)
However the same behaviour occurred.
After reviewing some similar threads, I also tried
keys = kb.getKeys(['right'], waitRelease=False, clear=False)
keys2 = kb.getKeys(['right'], waitRelease=True, clear=True)
however, this leads to the grating fading all the way as soon as a key is pressed and released (I suppose because the key event is not cleared and keeps firing on every frame).
Am I missing something here?