Detect Keyboard Input Matlab

前端 未结 4 860
不知归路
不知归路 2020-12-11 03:01

I have a simple question, although it\'s harder than it seems; I couldn\'t find the answer on the interwebs :O

I\'m writing a script in Matlab. What I want to do is

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-11 03:18

    In a matlab figure you can define a 'KeyPressFcn' that works similar to do what you ask.

    If you are in the console you have to work around that matlab is single threaded. Basically you need to halt the program flow to check for key presses.

    btw - also when you use 'KeyPressFcn' you will need to make some pauses so that Matlab will check if anything has happened.

    btw2 - I should also add during this pauses Matlab will not only read your key presses - but also do some housekeeping such as redrawing its window and stuff.

提交回复
热议问题