How to get input from user without asking to press enter?

35 views (last 30 days)
How to get input from user without asking to press enter at MATLAB prompt?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 6 Jul 2012
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

More Answers (0)

Categories

Find more on Desktop in Help Center and File Exchange

Products


Release

R2007a

Community Treasure Hunt

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

Start Hunting!