How can I find and use the codes for keyboard?

26 ビュー (過去 30 日間)
M G
M G 2011 年 11 月 24 日
Hello MATLAB users,
Could you please let me know how I can find the proper codes for each key in the keyboard and mouse and then use it in my script?
Suppose a user needs to press either "f","m" or "left mouse button" before importing female, male or children's name, respectively.
Thanks for your help :)

回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 11 月 24 日
You don't want the actual keycodes; MATLAB will decode them for you. See the code example at http://www.mathworks.com/matlabcentral/newsreader/view_thread/157527
Mouse buttons do not create key codes, and are not registered by getkey() or by KeyPressFcn or WindowKeyPressFcn callbacks: you need ButtonDownFcn or WindowButtonDownFcn instead, and then you look at the figure SelectionType property to figure out which mouse button was pressed (there is no explicit "left mouse", "right mouse", and so on, just single mouse event with "modifiers")

カテゴリ

Help Center および File ExchangeDesktop についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by