How do I determine if CapsLock is down?
How to tell if Capslock is on
BlitzMax Forums/BlitzMax Beginners Area/How to tell if Capslock is on Look for the little light on your keyboard? ;-)
Seriously though -- good question.
A quick test shows that the keycode returned when you *press* caps-lock is 20.
(Duh. And *after* the fact of finding this out I see that there is indeed a predefined constant of Key_Capslock that is set to 20) Anyway, that doesn't do a whole lot of good I guess, since it doesn't tell you the current state, just whether or not someone is actively holding it down at the moment.
The recently added GetChar() doesn't seem to detect Caps Lock at all (Since it isn't actually a character key, and has no ASCII value to return obviously)
Seriously though -- good question.
A quick test shows that the keycode returned when you *press* caps-lock is 20.
(Duh. And *after* the fact of finding this out I see that there is indeed a predefined constant of Key_Capslock that is set to 20) Anyway, that doesn't do a whole lot of good I guess, since it doesn't tell you the current state, just whether or not someone is actively holding it down at the moment.
The recently added GetChar() doesn't seem to detect Caps Lock at all (Since it isn't actually a character key, and has no ASCII value to return obviously)
On Windows:
GetKeyState(vbKeyCapital)
to check status.
Strict SetCapsLockKey(1) '1 for ON End Function SetCapsLockKey(newState) Const KEYEVENTF_KEYUP = $2 Const vbKeyCapital = 20 ' if the current state must be changed If GetKeyState(vbKeyCapital) <> newState ' programmatically press and release the CapsLock key keybd_event vbKeyCapital, 0, 0, 0 keybd_event vbKeyCapital, 0, KEYEVENTF_KEYUP, 0 EndIf End Function Extern "win32" Function keybd_event(bVk, bScan, dwFlags, dwExtraInfo) Function GetKeyState(nVirtKey) End ExternUse:
GetKeyState(vbKeyCapital)
to check status.
wait, what is this GetChar() command I hear about - is it only available after the core update?