Matlab - Detectar teclas especiales en Matlab

 
Vista:
Imágen de perfil de David Alejandro

Detectar teclas especiales en Matlab

Publicado por David Alejandro (4 intervenciones) el 17/04/2018 05:52:35
Estoy trabajando en una gui y quisiera que ejecutara un comando cuando presiono una tecla especial de la computadora. Con tecla especial me refiero a "enter", "tabulador", "shift", "control", "espacio", etc.

Por ejemplo:

1
2
3
4
5
6
7
8
9
if tecla == 'tabulador'       %Presiona la tecla tabulador 
      disp(presionaste la tecla tabulador)
 
elseif tecla =='control'
      disp(presionaste la tecla control)
.
.
.
end

Ojalá pudieran ayudarme.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de JOSE JEREMIAS CABALLERO
Val: 6.975
Oro
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

Detectar teclas especiales en Matlab

Publicado por JOSE JEREMIAS CABALLERO (5917 intervenciones) el 18/04/2018 05:00:12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function pushbutton1_Callback(hObject, eventdata, handles)
function pushbutton2_Callback(hObject, eventdata, handles)
function figure1_WindowKeyPressFcn(hObject, eventdata, handles)
m=eventdata.Key
if strcmp(eventdata.Key,'return')
    disp(['presionaste la tecla:' 'enter'])
     M=findobj('Tag','pushbutton1');
     set(M,'BackgroundColor',[0 1 0]);
else
    if strcmp(eventdata.Key,'space')
    disp(['presionaste la tecla:'  'barra espaciadora'])
      M1=findobj('Tag','pushbutton2');
      set(M1,'BackgroundColor',[0 1 0]);
    end
 
end
 
function figure1_WindowKeyReleaseFcn(hObject, eventdata, handles)
M=findobj('Tag','pushbutton1');
set(M,'BackgroundColor',[0 0 1]);
M1=findobj('Tag','pushbutton2');
set(M1,'BackgroundColor',[0 0 1]);



Saludos
JOSE JEREMIAS CABALLERO
Asesor de Proyectos con Matlab
Servicios de programación matla


http://matlabcaballero.blogspot.com
https://www.facebook.com/matlabcaballero
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar