try
    screens = Screen('Screens');
    whichscreen = max(screens);
    [myscreen,rect]=Screen('OpenWindow',whichscreen);
    DrawFormattedText(myscreen, 'PRESS THE SPACEBAR TO PROCEED', 'center', ...
    'center');
    Screen('Flip', myscreen);
    space = KbName('space');
    [secs, keyCode] = KbWait;
    while keyCode(space)==0
        [secs, keyCode] = KbWait;
    end
    screen('CloseAll');
catch
    Screen('CloseAll')
    rethrow(lasterror)
end