key pressed not recognized

4 views (last 30 days)
Ron Seligmann
Ron Seligmann on 30 Oct 2012
Have R2012a running on Win7. When using the following script I don't seem to be able getting the key pressed recognized. Script works on other computers. Help appreciated.
function youPress(~,eventdata)
if eventdata.Key== 'k'
beep
elseif eventdata.Key== 'd'
beep beep beep
end
end
  1 Comment
Walter Roberson
Walter Roberson on 30 Oct 2012
Which kind of callback is this registered against, and which graphic object?

Sign in to comment.

Answers (1)

Sean de Wolski
Sean de Wolski on 30 Oct 2012
If you just comment everything out:
function youPress(~,eventdata)
disp('hello world')
% if eventdata.Key== 'k'
% elseif eventdata.Key== 'd'
% beep beep beep
% end
end
And then put focus on the figure and press a key, do you see 'hello world' printed?

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!