Reading Arrow Key Input
Show older comments
What I'm basically trying to do is control a robot by using the arrow keys on the keyboard. I'm already familiar with outputting commands via MATLAB my main problem is how to read what arrow keys I'm pressing. Ultimately I would like to press an arrow button and have it displayed on the command window.
I came across this bit of code online. It works great but I need the keystrokes to be store in a variable (possibly as a number instead of a string) so I can output it. There may be a simple solution but since I don't really understand the code my attempt to edit it didn't work.
h_fig = figure;
set(h_fig,'KeyPressFcn',@(h_obj,evt) disp(evt.Key));
Thank You
Sayyid Khan
Accepted Answer
More Answers (0)
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!