Left ALT & Right ALT keys

Archives Forums/Win32 Discussion/Left ALT & Right ALT keys

Moraldi(Posted 2007) [#1]
Does anyone knows how to check the RIGHT ALT and/or the LEFT ALT keys presses from within C (or C++)
I know that WM_SYSKEYDOWN message contains this info but I didn't manage to handle

Thanks!


Timeslip(Posted 2007) [#2]
Use 'GetAsyncKeyState(0x12)' to check for either alt key. If you want to check for the left/right keys individually, use 0xa4 for left and 0xa5 for right, but iirc that only works on windows 2000/xp.


Moraldi(Posted 2007) [#3]
Thanks Timeslip for your help (yes, I want to check the left/right alt keys individually) but I read in the MSDN Library this:

"... Although the least significant bit of the return value indicates whether the key has been pressed since the last query, due to the pre-emptive multitasking nature of Windows, another application can call GetAsyncKeyState and receive the "recently pressed" bit instead of your application..."

From all these above I understand that if another application call GetAsyncKeyState() then my application will not respond...

EDIT: I checked your suggestion and it works fine...