Hi Rayle
the following only captures one keystroke at a time, but as long as the figure is active, no system shortcuts are executed, including shift F10, try it.
1.
Let me show you how to use figure to capture keystrokes
clear all;close all;clc
a='0';b='0'
S.fh = figure( 'units','pixels',...
'position',[500 500 200 260],...
'menubar','none','name','move_fig',...
'numbertitle','off','resize','off',...
'keypressfcn',@f_capturekeystroke,...
'CloseRequestFcn',@f_closecq);
S.tx = uicontrol('style','text',...
'units','pixels',...
'position',[60 120 80 20],...
'fontweight','bold');
guidata(S.fh,S)
function f_capturekeystroke(H,E)
S2 = guidata(H);
P = get(S2.fh,'position');
set(S2.tx,'string',E.Key)
assignin('base','a',E.Key)
evalin('base','b=[b a]')
end
function f_closecq(src,callbackdata)
selection = questdlg('Close This Figure?','Close Request Function','Yes','No','Yes');
switch selection
case 'Yes'
S.fh.WindowSyle='normal'
delete(gcf)
case 'No'
return
end
end
.
2.
Regarding the crux of the query
' .. to detect a keypress and initiate action based on what key was pressed and whether or not a given different key had been pressed first .. '
the variable b contains the log of all keystrokes, sequentially logged, so one can catch combinations like ctrl+S
One can build a 2 characters window and with a switch discern any string that should trigger desired events.
.
3.
For the mouse capture, a start point for your development could be Rodney Thomson example, one of many examples compiled in a bundle available in the File Exchange to start learning GUI development, but also directly available here
[EDITED, copy righted code removed]
.
test call
.
t = linspace(-5,5);
y = sinc(t);
f = figure;
plot(t, y, 'r');
set(f, 'WindowButtonMotionFcn', @(obj, event)cursorLocation(obj, event, 'BottomLeft', ' X: %.3f\n Y: %.3f', 'r'))
.
4.
May be you can get all shortcuts overloaded with Java, the solution may be in the following reference:
Undocumented Secrets of MATLAB - Java Programming
author: Mr Yair Altman
ed: CRC Press
.
if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance
John BG