How to use "getkey" correct ?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
I am currently using "getkey" but it appears to include some falts. The worst one is that it stops matlab and goes to the matlab main window, however the maylab script still runs, but it is hard to use without seeing the figure of my apllication.
What alternative functions can be used instead of "getkey" ?
best regards
Ole
채택된 답변
Star Strider
2025년 12월 12일
0 개 추천
I am not certain what you are doing. Two options could be waitfor or waitforbuttonpress. There are additional possibilities in the See Also section of both pages.
댓글 수: 9
Ole
2025년 12월 12일
Thanks for your answer. The waitforbuttonpress does almost work correct, with the exception that i have to press the key two time in order to get the input (still using "getkey")
Star Strider
2025년 12월 12일
My pleasure!
I am still not certain what you want to do.

might have functions that can do what you want. (The 'Control Flow' section is near the end of that page.)
.
Ole
2025년 12월 12일
I am using a long complex procedure which is polled starting by reading a character from the keyboard. the start of this procedure is:
w = 0;
while w == 0
w = waitforbuttonpress;
end
ch2 = getkey;
if ch2 == 27 % if key = "escape": Set exit
Exit = 1;
end
Walter Roberson
2025년 12월 12일
getkey() is a File Exchange contribution. There is no certainty that it still works in your release.
Ole
2025년 12월 12일
Yes, I know that getkey() is not centain to use. However I am not sure how else to read the keybard. Using the waitforbottonpressed did actually prevent the system from showing the matlab-window in front of my application-figure. Therefore, I need a way to read that key-code which is resulting in having waitforbottonpressed to return the value "1". (That I do not know).
So sorry for all my questions, I wrote my matlab code some 25 years ago as a 5 year of speartime-activity in trying to solve a mayor problem with arrays of microphones. The concept I developed did actually obtain a patent which has now expiered due to lifetime. I am now on pension and 83 years old, for what reason my brain is not what it used to be.
Best regards, and thaks a lot for your help
Ole.
Star Strider
2025년 12월 12일
My pleasure!
No wories about all your questions. That is what MATLAB Answers is for.
I apologise for not being able to solve your problem, since I am still not certain what it actually is.
Ole
2025년 12월 12일
My problem is that I am using "getkey", how else to read the code of the key pressed ?
Star Strider
2025년 12월 12일
Walter Roberson
2025년 12월 12일
Perhaps use a figure() or uifigure() WindowKeyPressFcn callback. https://www.mathworks.com/help/matlab/ref/matlab.ui.figure.html#buiwuyk-1-KeyPressFcn
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
