| Re: keyboard input [message #12929] |
Thu, 24 September 1998 00:00 |
J.D. Smith
Messages: 214 Registered: August 1996
|
Senior Member |
|
|
Rob MacLeod wrote:
>
> Folks,
>
> Simple, beginners questions, but I want to have some very basic control
> over a program via the keyboard. For example, viewing a set of images and
> use "n" for next image "p" for previous, etc. Widgets are overkill and
> more time than I am willing to commit. But instead a command that waits
> for keyboard input, returns the value entered, which I then process inside
> the program. Braindead stuff in any other language I have used but I
> cannot seem to find it in IDL (maybe it's me who is braindead on this one
> (-: ).
>
> If this matters, I need this for the Mac implementation of IDL 5
>
> Thanks,
>
How about:
repeat begin
k=get_kbrd(1)
print,'Got key '+k
endrep until k eq 'q'
Replace "Got key" with a case statement, or whatever you'd like to do
with the key string in your program. Braindead enough? I think a 2nd
grader could read this and understand what it means.
JD
|
|
|
|