필터 지우기
필터 지우기

Ask participants for button press?

조회 수: 13 (최근 30일)
Laurie Gerstenberger
Laurie Gerstenberger 2016년 9월 29일
댓글: Mihaela Duta 2016년 10월 11일
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
Laurie Gerstenberger
Laurie Gerstenberger 2016년 9월 30일
Yes,awesome! It worked. Thank you so much!
Mihaela Duta
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개)

카테고리

Help CenterFile Exchange에서 Timing and presenting 2D and 3D stimuli에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by