Enabling space bar and arrows as hot keys
29 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Image Analyst
il 4 Ott 2013
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 Commenti
Image Analyst
il 4 Ott 2013
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
il 4 Ott 2013
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?
Più risposte (1)
Jan
il 5 Ott 2013
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 Commenti
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!