The Matlab documentation definition for KeyPressFcn
is a "callback function invoked by a key press that occurs while the figure window has focus."
Similarly, the definition for WindowKeyPressFcn
is a "callback function invoked by a key press that occurs while either the figure window or any of its children has focus."
As far as I understand, the children of figures are entities like axes, plot objects, and annotation objects. If one of these children has focus, then its parent figure presumably also has focus (at least its handle would be returned by gcf
). Therefore, I don't see any practical distinction between KeyPressFcn
and WindowKeyPressFcn
other than that the former, by implication of its name lacking the term Window
, might also take effect when no figures are active, such as when operating in the command window (though this conjecture is in disagreement with the callbacks definition, which explicitly invokes the presence of a figure window).
Could someone pleas explain the difference between these two callback functions and when use of one over the other might be preferred?