views:

162

answers:

1

Is it possible to poll GetKeyboardState() as a replacement for a global keyboard hook?

+2  A: 

I suppose it depends on what you want to do, but probably not.
GetKeyboardState only gets the current state while with the hook you'll get all the keypresses as they come.
I'm not sure if you could even poll it fast enough to be sure to never miss any keypress, but even if you did, if for example the A key was pressed during one poll, and the A key still has the state of pressed during the next poll, how could you tell if that was one long or two fast keypresses.

ho1