Sign in to follow this  
Followers 0
Andrew Chen

How do I check if the user presses a key?

6 posts in this topic

I am trying to watch if the user presses [ESC] key, to terminate the program. Thanks

Share this post


Link to post
Share on other sites



I am trying to watch if the user presses [ESC] key, to terminate the program. Thanks

You can do this:
While 1
    HotKeySet("{ESC}", "_Exit")
WEnd

Func _Exit()
    Exit
EndFunc

Share this post


Link to post
Share on other sites

Thanks! If I put this while loop in the top of my code, will the rest still run, or will it be stuck in this while loop?

Share this post


Link to post
Share on other sites

Post your source and I'll show you where to put it.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

That code is wrong, hotkeyset shouldn't be in a while loop, it should be like this:

HotKeySet("{ESC}", "_Exit")

While 1
    Sleep(10)
WEnd

Func _Exit()
    Exit
EndFunc
Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

ahh okay, that makes everything much easier. Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0