You could use a global flag, something like this:
global clicked;
clicked = true;
Then, on your figure1_KeyPressFcn
function, you only call the switch
if the user has clicked, like this:
global clicked;
if clicked
switch eventdata.Key
case 'space'
clicked = false;
%% processing x task
...
end
end
And on both your pushbutton?_Callback
's, you add this:
global clicked;
clicked = true;
To set clicked
to true
and allow figure1_KeyPressFcn
to process space keys again.