-
Notifications
You must be signed in to change notification settings - Fork 27
/
handleKeypress.m
44 lines (40 loc) · 1.26 KB
/
handleKeypress.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function handleKeypress( src, evnt )
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% handleKeypress.m
%
% handles keyboard shortcuts
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global HANDLES handles PARAMS
% figure out how many subplots needed
savalue = get( HANDLES.display.ltsa,'Value' );
tsvalue = get( HANDLES.display.timeseries,'Value' );
spvalue = get( HANDLES.display.spectra,'Value' );
sgvalue = get( HANDLES.display.specgram,'Value' );
%determine which modifiers have been pressed.
if ~isempty( evnt.Modifier )
switch( evnt.Modifier{1} )
case 'control'
theKey = 'CtrlKeys';
case 'alt'
theKey = 'AltKeys';
case 'shift'
theKey = 'ShiftKeys';
end
else
theKey = 'DefaultKeys';
end
%make keypress struct
struct = eval( [ 'PARAMS.keypress.', theKey ] );
if isfield(struct, 'Key')%make sure that a key field is there
for x = 1:length( struct.Key )
if strcmp( evnt.Key, struct.Key( x ).name )%find the matching key
if eval( struct.Key( x ).param )
eval( struct.Key( x ).fn )
break;
end
break; %no duplicate key press so end loop
end
end
end