Getting arrow key presses in code without any figures
Show older comments
Is there a way to get key presses, including arrow keys, in an m script which does not produce or need figures?
I have browsed through mulltple entries from the MATLAB community pages but all of the m files involve figures. I do not want or need graphical input, just a user interaction with the keyboard. I do not want to use simulink. Just a plain m file.
Please give a detailed answer, I am unfamiliar with callbacks and find them very confusing. If this does not require a callback (after all no figure is involved), so much the better.
thanks
Accepted Answer
More Answers (1)
Walter Roberson
on 15 May 2024
0 votes
You can potentially use one of the routines from PsychToolbox; https://www.mathworks.com/matlabcentral/answers/143088-real-time-detect-keypress#answer_285124
The toolbox as a whole would be rather heavy for your needs, but the key detection routines are mex based and could potentially be extracted from the toolbox.
1 Comment
John Endler
on 16 May 2024
Moved: Voss
on 16 May 2024
Categories
Find more on Desktop in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!