[open] Double tap key when answering question
Hi, do anyone know why I need to tap the key twice in order to clear the canvas?
For the DISPLAY question part?
from openexp.canvas import canvas
my_canvas = canvas(exp)
my_canvas.text(sentence, center=False, x=60, y=350, max_width=None, color='black', bidi=True, html=True)
my_canvas.show()
Key clear sentence canvas and music
kb.get_key()
my_canvas.clear()
sound.stop()
Displays Question
if question and not question.isspace():
question = (question + yes_no)
my_canvas_question = canvas(exp)
my_canvas_question.text(question, center=True, x=None, y=None, max_width=None, color='black', bidi=True, html=True)
my_canvas_question.show()
question_response.get_key()
my_canvas_question.clear()
key = question_response.get_key()
# 1 is correct response and 2 is wrong not working properly
if correct_answer in key:
ParticipantResponse = 1
elif correct_answer not in key:
ParticipantResponse = 2
else:
ParticipantResponse = 0
exp.set('ParticipantResponse',ParticipantResponse)
exp.pygaze_eyetracker.log('ParticipantResponse ' +str(ParticipantResponse))
have this in the prepare script
kb = keyboard(exp,keylist= ['space'],timeout = 27000)
question_response = keyboard(exp,keylist= ['y','n'],timeout = 27000)
if answer == 1:
correct_answer = 'y'
else:
correct_answer = 'n'
Comments
Hi OlaNordrum,
it would really help us if you could display your code in orderly fashion. Please check the "use Markdown extra syntax" link in the tips section. Basically, it you put 4 spaces in front of your code, or enclose your code blocks in three ` characters (so before and after the code block), this should be taken care of.
Hi,
Do I understand correctly, the first time you are calling
kb.get_key()
, does work (so, it proceeds tomy.canvas.clear()
right away), but the second time with `question_response.get_key(), it needs two keypresses?Eduard