Enabling space bar and arrows as hot keys
29 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Kyle Stanhouse
el 4 de Oct. de 2013
Respondida: Jan
el 5 de Oct. de 2013
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 comentarios
Respuesta aceptada
Image Analyst
el 4 de Oct. de 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 comentarios
Image Analyst
el 4 de Oct. de 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
el 4 de Oct. de 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?
Más respuestas (1)
Jan
el 5 de Oct. de 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 comentarios
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!