Logging multiple key presses and duration between key presses
Hello
I am new to Python and am trying to set up an experiment in which the subject looks at an ambiguous image for a minute, and presses the left or the right key to indicate what they are seeing. I would like to collect the key presses and the timings of the key presses in a log file. I have tried to do this using pygame.event.get () and specifying the time of KEYDOWN for each press as time - t0, but am not sure how to specify both the name of the key (K_RIGHT; K_LEFT) and also the state (KEYDOWN). I would be very grateful for any help!
Thank you
Comments
As you say. You are new. Some questions:
1. Do you request just one keypress? L or R? Then just use a keyboard response.
2. Do you request several keypresses and know how many there will be? Just use your amount of keyboard responses (Maybe in a for loop?).
3. Do you request an uncertain number of keypresses (maybe NONE)?
--> You may find some solutions in other forum discussions on this topic
e.g.
http://forum.cogsci.nl/index.php?p=/discussion/3356/logging-multiple-key-duration-while-video-running
http://forum.cogsci.nl/index.php?p=/discussion/1199/solved-log-time-and-duration-of-multiple-key-presses
http://forum.cogsci.nl/index.php?p=/discussion/2524/logging-simultaneous-key-presses
Hope this helps
Stephan