Equivalent of key/mouse listener?

Hello,
I have to code a program in c++ but I'm not really used to it (not a complete noob either).
It's almost done but I struggle with this. I have to check if a key is pressed and if this key is pressed I have to check if the user is draging the mouse and then do something.
If I was doing this in java or c# I would use listener but how can I do this in c++?
Is it bad to make an infinite loop?

Thank you
You check for a key being pressed in Windows with the WinAPI function "GetAsyncKeyState()": http://msdn.microsoft.com/en-us/library/windows/desktop/ms646293(v=vs.85).aspx

Is it bad to make an infinite loop?

Not if you design it correctly. This isn't a waiting function, it checks if the status of the key has changed since the last call to made to it and then immediately returns the result to you. So this can easily pin the CPU with calls to this function if you just use it on its own. But if you use the Windows message queue correctly it shouldn't be an issue.
Topic archived. No new replies allowed.