MATLAB: How to get input from user without asking to press enter

currentcharactergetchinputMATLABwaitforbuttonpress

How to get input from user without asking to press enter at MATLAB prompt?

Best Answer

The ability to take input from user without asking to press enter is not directly available through any of the features in any of the MATLAB releases.
As a possible workaround, WAITFORBUTTONPRESS and 'CurrentCharacter' can be used. Following is an illustrative example:
w = waitforbuttonpress;
if w
p = get(gcf, 'CurrentCharacter');
disp(p) %displays the character that was pressed
disp(double(p)) %displays the ascii value of the character that was pressed
end