It looks like you're new here. If you want to get involved, click one of these buttons!
Is there a way to set the duration of a sketchpad as either keypress or mouseclick whichever comes first?
Thanks in advance
Thank you for your interest in OpenSesame!
No, there's no way to do that through the GUI, but you can set the duration to '0' and add a simple inline_script after the sketchpad:
# Import and create mouse and keyboard objects
from openexp.keyboard import keyboard
from openexp.mouse import mouse
my_keyboard = keyboard(self.experiment, timeout=5)
my_mouse = mouse(self.experiment, timeout=5)
# Wait until a key has been pressed or button has been clicked
start_time = self.time()
resp, time = my_keyboard.get_key()
if resp != None:
resp = my_keyboard.to_chr(resp)
resp, pos, time = my_mouse.get_click()
if resp != None:
# Store the response
For more information, see
Hope this helps!
There's much bigger issues in the world, I know. But I first have to take care of the world I know.
Thanks, that helps a lot.
Very helpful answer. Thanks too.
One more detail:
If I only want certain keypresses, lets say F, G,H, and J, plus any mouse clicks, where do i insert this?
resp, time = my_keyboard.get_key(f;g;h;j)
The general procedure is explain here and here
If you want to use both, mouse and keyboard responses, you should sample responses in a loop, e.g. like so:
<br />kb = keyboard(keylist=['j', 'f','g', 'h'], timeout=20)
# have a low timeout, so that the experiment will not freeze in anticipation for a keyboard response)
ms = mouse(timeout = 20)
t0 = clock.time()
while clock.time()-t0 < 5000: # have 5 seconds as response time limit to avoid infinite loops and such
key, time = kb.get_key()
if key != None:
button, position, timestamp = my_mouse.get_click()
if button is not None:
I hope this helps.