For text input the situation is pretty much the same as for text output. It can be done, but it requires inline scripting. Below you see simple script, adapted from this discussion, that gives a very simple example of how you can implement right-to-left text input.
For more information, see the code comments in the script and these documentation pages:
from openexp.canvas import canvas
from openexp.keyboard import keyboard
my_canvas = canvas(exp)
my_keyboard = keyboard(exp)
resp = u'' # Here we store the response
# Start with a clean canvas
my_canvas.clear()
my_canvas.text(resp)
my_canvas.show()
while True:
# Get a keyboard response
key, time = my_keyboard.get_key()
# If return is pressed the loop should be exited.
if key == u'return':
break
# Handle backspace by removing the last character
if key == u'backspace':
resp = resp[1:]
else:
# Convert 'space' to a space character. Other
# characters can be recoded in the same way.
if key == u'space':
key = u' '
resp = key + resp
# Show the canvas
my_canvas.clear()
my_canvas.text(resp)
my_canvas.show()
# Save the response
self.experiment.set('response', resp)
Dear Sebastiaan
Thanks for the information. I am just want to add to my question that the program needs to wait 30 seconds then the participants can write all of the words they can, so the target response isn't a single key. Does this make any difference in the inline_script?
Masoud
The script collects a string of text input until the participant presses return. So I imagine that's what you need. If you want to add a 30 s pause to your experiment, you can simply insert an advanced_delay item (or some other item that introduces a pause) before the inline script.
Comments
Hi Masoud,
For text input the situation is pretty much the same as for text output. It can be done, but it requires inline scripting. Below you see simple script, adapted from this discussion, that gives a very simple example of how you can implement right-to-left text input.
For more information, see the code comments in the script and these documentation pages:
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Dear Sebastiaan
Thanks for the information. I am just want to add to my question that the program needs to wait 30 seconds then the participants can write all of the words they can, so the target response isn't a single key. Does this make any difference in the inline_script?
Masoud
The script collects a string of text input until the participant presses
return. So I imagine that's what you need. If you want to add a 30 s pause to your experiment, you can simply insert anadvanced_delayitem (or some other item that introduces a pause) before the inline script.Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!