Prevent accidental capslock press

Share your favorite FastKeys commands
Post Reply
prasad383
Posts: 10
Joined: Oct 18th, ’19, 14:43

Post by prasad383 » Mar 13th, ’20, 17:37

Accidental Capslock presses are annoying while typing, at least for me..
Following script ignores the accidental Capslock press and toggles Capslock state on or off only when you press and hold it for a certain time period, for eg. 0.5 second.. This might be useful for someone like me out there.. This is not my script-- i have copied from net and modified it.

Code: Select all

$Capslock::

KeyWait, CapsLock, T0.5      ; half a second - change to your preference
If ErrorLevel
{
   	if GetKeyState("CapsLock", "T") = 1
	{
		SetCapsLockState, off 
		soundbeep, 100, 100
	}
	else if GetKeyState("CapsLock", "F") = 0
	{
		SetCapsLockState, on
		soundbeep, 100, 100
	}
}
Else 
   return

User avatar
Tom
Posts: 362
Joined: Nov 24th, ’15, 23:39

Post by Tom » Mar 15th, ’20, 21:00

Very useful script, thanks for posting.
Post Reply