to write a code for esc key

조회 수: 15 (최근 30일)
PA
PA 2022년 7월 7일
편집: Prathamesh Kulkarni 2022년 7월 7일
how to write a code for when we press the esc key from keyboard it close for uifigure

답변 (1개)

Prathamesh Kulkarni
Prathamesh Kulkarni 2022년 7월 7일
I understand you want to close uifigure after pressing escape key.
For that you can set the KeyPressFcn property of the uifigure as a function eg. keycall
and then check if the pressed key is escape, if it is then you can use close() command.
a = uifigure;
set(a,'KeyPressFcn',@keycall)
function keycall(a, e)
if isequal(e.Key, 'escape')
close(a);
end
end
  댓글 수: 2
PA
PA 2022년 7월 7일
Thanks and can i use keyReleaseFcn?
Prathamesh Kulkarni
Prathamesh Kulkarni 2022년 7월 7일
편집: Prathamesh Kulkarni 2022년 7월 7일
Yes you can use key release function as well.
This documentation will give you idea about the feature and implementation of both functions.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by