I've been trying to make a piano in MATLAB (without sound, thus far) using my keyboard to play the piano instead of the mouse. So far I've been able to perform the "execution" of one pushbutton, but when I try to use another one it will not execute.
% --- Executes on key press with focus on figure1 and none of its controls.
function figure1_KeyPressFcn(hObject, eventdata, handles)% 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)
switch eventdata.Key case 'c' uicontrol(handles.C) C_Callback(handles.C,[],handles) case 'd' uicontrol(handles.D) D_Callback(handles.D,[],handles)end
This is how the KeyPressFcn looks like in my m.file. I haven't yet done the whole piano, only the C and D key. As I mentioned, I can press one button, and it will be "marked", but I can't do both C and D in one run.
Thanks in advance!
Best Answer