Ask participants for button press?

12 visualizaciones (últimos 30 días)
Laurie Gerstenberger
Laurie Gerstenberger el 29 de Sept. de 2016
Comentada: Mihaela Duta el 11 de Oct. de 2016
Hi guys,
I programmed an experiment and I am rather new to Psychtoolbox and Matlab and one thing is not quite working. I began to try to code the sequence by myself and then I just copied a piece of code from the psychtoolbox tutorial page and it is still not working. That's why assume there might be another problem I haven`t thought about?
I display two pictures in my experiment and I want participants to answer with the left respectively right arrow key before the next pair of pictures is shown.
Here is what I did:
leftKey=KbName('LeftArrow');
rightKey=KbName('RightArrow');
escape=KbName('ESCAPE');
resp==true;
while resp==true;
[keyIsDown,secs,keyCode]=KbCheck;
if keyCode (escapeKey)
sca;
return
elseif keyCode(leftKey)
response=1;
resp=false;
elseif keyCode(rightKey)
response=2;
resp=false
end
end
Screen('Flip',window)
This works to escape but it does not register any answers :(.
I have also tried
while(~keyCode(leftKey))
[keyisDown,sec,keyCode]=KbCheck;
end
which unforuntnately does not switch to the next screen either.
And just to check whether left button presses are registered in any way, I wrote:
while (~keyCode(leftKey))
[keyisDown,sec,keyCode]=KbCheck;
end
... a left button press doesn't let me quit the loop either...
THANKS!!!!
  3 comentarios
Laurie Gerstenberger
Laurie Gerstenberger el 30 de Sept. de 2016
Yes,awesome! It worked. Thank you so much!
Mihaela Duta
Mihaela Duta el 11 de Oct. de 2016
I would also suggest you add as a standard at the top of your experiment scripts the command
KbName('UnifyKeyNames');
As the help for KbName function states, this will ensure that at least the names of special keys (like cursor keys, function keys and such) will be shared between operating systems.
When getting inspiration from other people's scripts, or when migrating your own scripts to a computer with a different operating system that the one originally used to debelop the scripts, you may encounter issues with key name mapping. The above command will avoid such issues.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Installation and Operational Settings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by