Getting arrow key presses in code without any figures
显示 更早的评论
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
采纳的回答
更多回答(1 个)
Walter Roberson
2024-5-15
0 个投票
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Desktop 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
