Fix repeated keystrokes without destroying AutoHotkey scripts?
I have a mechanical keyboard problem where sometimes 1 keypress registers as 2. I solved this by installing Keyboard Chattering Fix
and setting a minimum 50ms
delay requirement between key presses.
The issue is that this ruins my AutoHotkey scripts which require the ability to type really quickly.
So is there another way to fix my keyboard issue?
If you do the chattering fix in AutoHotkey itself (instead of using Keyboard Chattering Fix
, which presumably is a separate utility), then you wouldn't break anything else you have running in AutoHotkey.
I have done something similar to this by just defining a bunch of hotkeys to rate limit how fast they can be detected or sent. Your mileage may vary.
Hotkey Definitions
Space::ti92_rateLimit(needBrackets:=True)
a::rateLimit()
b::rateLimit()
...
z::rateLimit()
You can see that this might break down when using modifiers. You could also try variations on the hotkey to detect the modifiers and use *
in the hotkey definition instead, but I'm not sure how extensive of a fix you need. If you go this route and want to debug, add a ToolTip
or MsgBox
into the rateLimit()
routine to display A_ThisHotkey
when called.
Code
rateLimit(needBrackets:=False) {
static lastHotkey
static lastCall
if ((lastHotkey=A_ThisHotkey) && (lastCall-A_TickCount)>50))
SendInput % needBrackets ? "{" A_ThisHotkey "}" : A_ThisHotkey
;Sleep 20 ; output rate limit
lastHotkey:=A_ThisHotkey
lastCall:=A_TickCount
}