Computer Science Canada

How do you write a loop that exits when any key is pressed?

Author:  sarm2005 [ Tue Mar 11, 2008 12:50 pm ]
Post subject:  How do you write a loop that exits when any key is pressed?

well?

Author:  BigBear [ Tue Mar 11, 2008 12:52 pm ]
Post subject:  Re: How do you write a loop that exits when any key is pressed?

First I am wondering if this has to be a loop. Input.Pause waits for input then continues the program. If this isn't what you are looking for please provide more information. Hope this helps.

Author:  sarm2005 [ Tue Mar 11, 2008 1:18 pm ]
Post subject:  Re: How do you write a loop that exits when any key is pressed?

Yeah. I need it to be a loop since I want something else to happen every so often if a key is not pressed.

Author:  Sean [ Tue Mar 11, 2008 1:37 pm ]
Post subject:  Re: How do you write a loop that exits when any key is pressed?

Well, a simple if statement and an Input.KeyDown is required.

You want it to detect if a key was pressed then perform this action:

Turing:

exit


It will exit when that certain button you assigned it to exit upon is pressed.

Author:  Mackie [ Tue Mar 11, 2008 1:48 pm ]
Post subject:  RE:How do you write a loop that exits when any key is pressed?

code:
loop
    % Do stuff
    exit when hasch
end loop


Easy way.

Author:  sarm2005 [ Tue Mar 11, 2008 1:58 pm ]
Post subject:  Re: How do you write a loop that exits when any key is pressed?

Ok. That works. Thank you.

Author:  Sean [ Tue Mar 11, 2008 2:16 pm ]
Post subject:  Re: How do you write a loop that exits when any key is pressed?

Mackie, I wasn't trying to give it to him, was just trying to see if he could do it Razz


: