Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

keyboard presses before their time

Hi,
I would like to know how to ignore keyboard presses that happened before the keyboard input of the sketchpat (I think that this is what "Flush key pending events" does for the keyboard_response item)
I have a sketchpad A that lasts 2 minutes and then another sketchpad B with duration sets to "keypress". I noticed that if you press something during the sketchpad A, after the two minutes the sketchpad B gets skipped. How can I make that sketchpad B ignores the keyboard presses of sketchpad B?

Thanks,
Bruno

Comments

  • Hi Bruno,

    The easiest way is probably to set the duration of the sketchpad to 0, and then use a keyboard_response to wait for the keypress.

    Cheers!
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • Thanks for the fast answer, but it's still not working. I'm attaching a minimal example, if you press anything during the "wait" sketchpad, then the "press" sketchpad gets skipped.

    Bests,
    Bruno

  • Right, I see. You can add a keyboard_response with a 0 ms timeout between the two sketchpads. That will flush pending key presses but not actually wait for a key press.

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • Do you mean like this? It's still not working correctly.

  • HI Bruno,

    Yes exactly. Are you running on Linux (or perhaps Mac OS)? For some reason flushing doesn't work there, but I'm not sure why. On Windows it will.

    Cheers,
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • Hey guys,

    It is reminding me a little bit the issue I had there but with mouse response:
    http://forum.cogsci.nl/index.php?p=/discussion/4028/reseting-mouse-position-between-mouse-responses#latest

    Another way to fix it would be to create a ghost keyboard response between sketchpad.
    Just tried it on OSX and it works apparently (see the file).

    Best,

    Sylvain

  • Hi,
    I'm using Linux (and also the experiment is running in Linux). Sylvain's workaround didn't work either. Any other ideas?

  • sorry to bother with this, but what can I do besides putting a "don't press anything" in the waiting sketchpad?

  • Hi Bruno,

    It took me a while to figure this out, but it's fixed in the latest prerelease of 3.2.5 (now 3.2.5.a6). You can update through pip or, if you're running Ubuntu, through ppa:smathot/opensesame-kuhn.

    Alternatively, you can simply insert the following inline_script at places where you want to force the flush from happening:

    import pygame
    pygame.event.pump()
    

    Cheers!
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

Sign In or Register to comment.