Ask participants for button press?
10 次查看(过去 30 天)
显示 更早的评论
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 个评论
Mihaela Duta
2016-10-11
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.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!