MATLAB: How to pause until the “return” key is pressed

currentkeypause

I have a gui that I need to have wait until the return key is pressed before advancing. Below is my code but I keep getting an error saying:
Error using == Matrix dimensions must agree.
Error in RunDlg_bab>ok_Callback (line 388) if currkey=='return'
Below is my code:
currkey=0;
% do not move on until enter key is pressed
while currkey~=1
pause; % wait for a keypress
currkey=get(gcf,'CurrentKey');
if currkey=='return'
currkey==1
else
currkey==0
end
end
Any sort of help would be really appreciated!

Best Answer

You may be able to use waitforbuttonpress.