What is the difference between Getkeystate() and Getasynckeystate()?

Asked

Viewed 616 times

1

I’ve always used the GetKeyState() to know if the user is pressing a key, but I see that many people use more the GetAsyncKeyState(). With that came to me the following doubts:

  1. What is the difference between the 2?

  2. When should I use each?

  3. In an application that I must have the best performance and speed possible, which I should use?

  • One detects pressing and stops running, the other continues running the current thread asynchronously. In theory, all functions that have Async in the name, must return a Task asynchronous.

1 answer

-1

Apparently it has to do with return of the method, in the documentation there is a specific explanation: "The key status returned from this Function changes as a thread reads key messages from its message Queue. The status does not reflect the Interrupt-level state Associated with the hardware. Use the Getasynckeystate Function to Retrieve that information."

Knowing which one to use depends on the result you want to get, since the methods return different information.

  • it is always interesting to translate citations/explanations into Portuguese, not everyone understands English, even working/studying with it

  • I just quoted the part where the documentation refers to the question, so that he can find it more easily.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.