I just discovered that the caps lock and shift key (and probably some more of the keys) affect all of the keyboards connected to the computer. (one of the hazards of testing a program that I coded, I only have two hands so it took me ages to realize a problem like this) So separating the keystrokes is fine, but the shift/caps locks drives everything crazy (When one user shifts to capitalize, all users' input at that moment are capitalized as well)
Can I capture Capslock and Shift keypress in FormKeyPress?
Anywhere else for that matter?
Can I save a Shift keypress? (so I can properly apply the 'shift' to the respective user input)
Any other suggestion to solve this problem is welcome as well.
to check if shift ley is down try this:
if GetKeyState(VK_SHIFT)<0 //tests if shiftkey is down
then ShowMessage('shift key is down'');
and to detect if caps lock is on try this:
if Odd(GetKeyState(VK_CAPITAL)) //tests if caps lock is on
then showmessage('caps lock is on');
and if you want to check status of both shift and capslock :
if Odd(GetKeyState(VK_CAPITAL)) then
if GetKeyState(VK_SHIFT)<0 then
showmessage('capslock is on and shift key is down too')
else
showmessage('capslock is on but shift key is NOT down');
getkeystate is a windows api function you can read more about it here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With