My keyboard is buggy right now and keys are double typing when they're not meant to. I found this autohotkey script online that ignores keystrokes if they're registered again in a very short timespan. The code works by listing all the broken keys contiguously in a string but I'm not sure how to list my backspace key. The documentation states the backspace is key is just backspace but it's not working for me. This is what I have so far.
;List all your broken keys between quotes below. I.e. if your broken keys are g and f then the line below shoud be
;brokenKeys := "gf"
brokenKeys := "fosbaituwrvlk"
;timepan in which subsequent keystrokes should be ignored.
fixOffset := 80
;These are typical values for a starter AHK script
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
;This array will hold timers for each broken key
lastTimePressed := {}
;Create timer with current time for each broken key
Loop, Parse, brokenKeys
{
lastTimePressed[A_LoopField] := A_TickCount
}
;lastTimePressed := A_TickCount
;Assign a hotkey handler for each broken key
Loop, Parse, brokenKeys
{
keyName :=
Hotkey, $%A_LoopField%, HotKeyHandler
}
HotKeyHandler:
pressedKey := SubStr(pressedKey,2)SubStr(A_ThisHotKey,2)
sinceLastPress := A_TickCount - lastTimePressed[pressedKey]
if (sinceLastPress > fixOffset) { ;send the hijacked key only when sufficient time has passed
lastTimePressed[pressedKey] := A_TickCount
Send %pressedKey%
}
return
EDIT: I've updated my code. Currently after I click backspace, the backspace key registers but after that all the brokenKeys no longer respond. From debugging, the pressedKey variable seems to have been affected by clicking backspace and so lastTimePressed[pressedKey] is not working in the hotKeyHandler function.
;List all your broken keys
brokenKeys := "f|o|s|b|a|i|t|u|w|r|v|l|k|'|backspace"
;timepan in which subsequent keystrokes should be ignored.
fixOffset := 80
;These are typical values for a starter AHK script
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
;This array will hold timers for each broken key
lastTimePressed := {}
;Create timer with current time for each broken key
Loop, Parse, brokenKeys, |
{
lastTimePressed[A_LoopField] := A_TickCount
}
;lastTimePressed := A_TickCount
;Assign a hotkey handler for each broken key
Loop, Parse, brokenKeys, |
{
keyName :=
Hotkey, $%A_LoopField%, HotKeyHandler
}
HotKeyHandler:
pressedKey := SubStr(pressedKey,2)SubStr(A_ThisHotKey,2)
sinceLastPress := A_TickCount - lastTimePressed[pressedKey]
if (sinceLastPress > fixOffset) { ;send the hijacked key only when sufficient time has passed
lastTimePressed[pressedKey] := A_TickCount
if (pressedKey == "backspace"){
Send {backspace}
} else {
Send %pressedKey%
}
}
return