How to request user input to press Esc or Enter ?
Mostrar comentarios más antiguos
% this is a pseudo-code I wrote just to give an idea about what I am trying to achieve:
answer = input('Please enter Esc to exit this code or Enter to continue:');
keepRunning = true;
while (keepRunning)
if (answer ~= Esc && answer ~= Enter) % If the user does not input either Esc or Enter
answer = input('ERROR. Please enter Esc to exit this code or Enter to continue:');
elseif (answer == Esc) % Exit this code
disp('exit the code')
keepRunning = false;
return
elseif (answer == Enter) % Continue this code and do stuff
disp('continue to run this code')
keepRunning = false;
continue % or do stuff here
end
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Software Development en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!