필터 지우기
필터 지우기

Enabling space bar and arrows as hot keys

조회 수: 8 (최근 30일)
Kyle Stanhouse
Kyle Stanhouse 2013년 10월 4일
답변: Jan 2013년 10월 5일
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

채택된 답변

Image Analyst
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
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
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
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'

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by