to write a code for esc key

13 次查看(过去 30 天)
PA
PA 2022-7-7
how to write a code for when we press the esc key from keyboard it close for uifigure

回答(1 个)

Prathamesh Kulkarni
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
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