Enabling space bar and arrows as hot keys
29 次查看(过去 30 天)
显示 更早的评论
Hello,
I'm trying to enable hot keys to execute functions in my Matlab script. In particular, I'd like to use the space bar and arrow keys. I've implemented the infrastructure to handle the event of a key press, and have successfully associated certain letters with functions, but i can't find any documentation that explains how i refer to the space bar and arrows. To be clear I just need to know the string Matlab uses to indicate the space bar and the arrow keys so that I can have them initiate functions the same way i've done with letter keys.
Thanks, Kyle
0 个评论
采纳的回答
Image Analyst
2013-10-4
Just check out all keys for the value they return in the keypress callback function, and note what values the arrow and space bar return. I bet the space bar returns 32 but I don't know the arrow key values off the top of my head but you can easily find out.
2 个评论
Image Analyst
2013-10-4
Kyle's answer moved here since it's a response to my Answer, not an answer in itself:
thanks for the reply!
it seems to return ' ', or an empty string for both space bar and the arrow keys. i can now get the space bar to work with ' ' but the arrow keys are still a mystery....
Image Analyst
2013-10-4
Kyle, you're looking at it as a character. What is it's ASCII value? Like a space = 32, '0' = 48, 'A' = 65, etc. What is the value of an arrow key?
更多回答(1 个)
Jan
2013-10-5
The 2nd input of the KeyPressFcn:
figure('keypressfcn', @(FigH, EventData) disp(EventData))
Now press on the desired keys and see the values of the EventData, e.g.
Character: ''
Modifier: {1x0 cell}
Key: 'rightarrow'
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!