Try this:
if (GetKeyState(VK_CONTROL)&0x80)
{ if ((nChar==_T('z'))||(nChar==_T('Z')))
{ // indicate activity
Beep(800, 50);
}
}
Additional Information:
From MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646301(v=vs.85).aspx
The function GetKeyState
retrieves the status of the specified virtual key. The status specifies whether the key is up, down, or toggled (on, off—alternating each time the key is pressed).
The key to check is the control-key, ie: VK_CONTROL. You can also refer to GetAsyncKeyState
for more supported key name macro.
The operation (&0x80) is checking for the single high-order bit (MSB) of SHORT (8-bits)
Return value: SHORT
If the high-order bit is 1, the key is down; otherwise, it is up.
If the low-order bit is 1, the key is toggled