-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfigureKeyPressFcn.m
More file actions
31 lines (28 loc) · 826 Bytes
/
Copy pathfigureKeyPressFcn.m
File metadata and controls
31 lines (28 loc) · 826 Bytes
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
function figureKeyPressFcn(hObject, eventdata, handles)
global w;
global v;
% hObject handle to figure1 (see GCBO)
% eventdata structure with the following fields (see FIGURE)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
% add this part as an experiment and see what happens!
%eventdata % Let's see the KeyPress event data
disp(eventdata.Key) % Let's display the key, for fun!
switch(eventdata.Key)
case 'w'
v = 0.02
case 's'
v = -0.02
case 'a'
w = 0.02
case 'd'
w = -0.02
case 'q'
v = 0
case 'e'
w = 0
otherwise
end
end