Borrar filtros
Borrar filtros

Psychtoolbox - exit out of loop with keypress

20 visualizaciones (últimos 30 días)
Harriet Dempsey-Jones
Harriet Dempsey-Jones el 14 de Jun. de 2019
Hi everyone,
I was wondering if someone could help - I am having a bad computer day. I want to make a really simple program where a
  • random number is presented on screen
  • the program randomly selects whether to +1 or -1 to that number
  • if it chooses to add one, play a high tone - and +1 to the starting number
  • if it chooses to subtract '' low tone '' -1
  • And to keep doing this until a key press happens (enter or escape or something)
I have put something together that basically works, aside from the exiting out on keypress - the program does not seem to get/ respond to key presses inside the program i.e., my KbCheck at line 98 does not seem to work. As I press it just types into the main screen.
keyIsDown = 0; % initialise to 0
while 1 % keep running until Q is pressed
[keyIsDown, secs, keyCode] = KbCheck;
FlushEvents('keyDown');
if (keyIsDown)
if keyCode(escKey)
ShowCursor;
Screen('CloseAll');
return
else
end
end
The thing I used to wait until mouse is clicked between trials works but looks a bit messy
clear buttons
[~,~,buttons]=GetMouse;
while ~any(buttons)
[~,~,buttons]=GetMouse;
end
clear buttons
[~,~,buttons]=GetMouse;
Any help would be greatly appreciated!

Respuestas (0)

Categorías

Más información sobre Timing and presenting 2D and 3D stimuli en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by