Here’s an entry from a long-time user. Honestly speaking, I’m surprised why this entry has not been Picked yet. It was initially posted in 2005. It’s a straight-forward tool that accomplishes something that I often need to do, which is to get user keyboard input. When I am developing an app, then I can make use of KeyPressFcn or WindowKeyPressFcn. But if I don’t have a figure window, it becomes a bit tricky. Jos’s getkey makes it easy for me. It actually creates an invisible figure to capture the key input. It’s a modal figure so it doesn’t lose focus. The simplest syntax is this
ch = getkey;
with additional syntax for extra useful features.
Thanks for making things easier, Jos!
Get the MATLAB code
Published with MATLAB® R2018b