Filter löschen
Filter löschen

Ask participants for button press?

13 Ansichten (letzte 30 Tage)
Laurie Gerstenberger
Laurie Gerstenberger am 29 Sep. 2016
Kommentiert: Mihaela Duta am 11 Okt. 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 Kommentare
Laurie Gerstenberger
Laurie Gerstenberger am 30 Sep. 2016
Yes,awesome! It worked. Thank you so much!
Mihaela Duta
Mihaela Duta am 11 Okt. 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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by