I have keyboard control with keystrokes in a GUI I wrote
using keypressFCN but was hoping that there is a simpler way
to do this kind of thing.
Now I have:
key = input('k to go forward, j to go back','s');
but the user has to press the letter and then enter.
Thanks!
J
>Now I have:
Doing in using keypressFCN -is- the easy way.
If you want single character I/O from the keyboard, you would
need to go in to the Java level (speculating), or you would need
to use an ActiveX control or mex routine, or you would need to use
a serial object. If this all doesn't sound portable, it's because it
isn't: what you might perhaps do if you have the Matlab desktop running
is different than if the desktop and jvm are turned off and you
are working over a unix pty or serial port.
And you need to consider: is 'shift' a keystroke? Is 'control'? What
'keystrokes' are involved if the user holds down a key to the point
where autorepeat would normally be triggered?
If you just want two options, such as forward and back, you
might want to consider using the figure buttondownfcn; if
you examine the selectionstate property, you can figure out which mouse
button was pressed.
--
"There are some ideas so wrong that only a very intelligent person
could believe in them." -- George Orwell
My GETKEY function may offer a solution. It can catch all
keystrokes, including shift, ctrl, etc. See
http://www.mathworks.com/matlabcentral/fileexchange/loadFile
.do?objectId=7465&objectType=FILE
(beware of line wraps)
hth
Jos
the getkey function is a nice solution to my problem. It
worked perfectly. Thanks!
J