For those who don't know, if you try to enable a keyPressFcn in a figure, it will override any keyPressFcn set in the figure handle anytime datacursormode, pan, rotate3d, or zoom are turned on. Next, it enables a listener which prevents further access to keyPressFcn.
Walter Roberson nicely came up with the fix to re-enable keyPressFcn functionality by disabling the listener, linked and copied below. However; it turns out you can easily break this fix by again turning on any of the interactive data tools (datacursormode, zoom, pan, rotate3d), which poses a large problem in my application which requires the user to explore the data. When these tools are turned back on, their default behavior resets the keyPressFcn.
I could use Roberson's fix if I had a way to monitor when the figure's keyPressFcn gets reset by the data tools. Unfortunately, I have no experience with programming event handlers.
If you have followed up to here, my questions are : Is there a way to monitor when the figure's keyPressFcn is modified? If so, how would I build an event handler to handle this event? If this is possible, the listener, when notified, could just reinsert Robinson's code.
< Robinson's Fix>
h = zoom(zfigh);
set(h, 'Enable', 'on');
hManager = uigetmodemanager(zfigh);
set(zfigh, 'KeyPressFcn', newkeyhook );