Capturing keystrokes with GetAsyncKeyState

An easy way to capture keystrokes in an application even if it is not the active one is by using the API function, GetAsyncKeyState, of the User32 DLL.

The trick is to set up a timer that regularly checks for the state of certain keys with GetAsyncKeyState

Here is an example: