Skip to content

Instantly share code, notes, and snippets.

@QuietNoise
Last active June 28, 2024 21:36
Show Gist options
  • Save QuietNoise/8339ec2cc8607978a8df3c290e2f453c to your computer and use it in GitHub Desktop.
Save QuietNoise/8339ec2cc8607978a8df3c290e2f453c to your computer and use it in GitHub Desktop.
G910 Keyboard Fix for double typing problem

G910 Keyboard Fix

What does this script do?

It's a workaround for broken G910 Logitech keyboards (possibly other keyboards too) whereby some keys occasionally register multiple keystrokes for one kkkkkeypress. The key bug appears because keyboard registers multiple keystrokes in a very short timespan even though you pressed the key only once. This script makes it so the subsequent keystrokes registered in a very short timespan are ignored thus outputing the key only for the first stroke.

How to use this fix?

You need install AutoHotkey v1 (Windows only). https://www.autohotkey.com/. A software to hijack keystrokes and assign them different functions. Note that year later after I've made this script that AutoHotkey v2 was released and this gist is not compatible with it. However, AHK v1 and v2 can run on the same computer without conflict. Then download the G910 Keyboard Fix.ahk file above, change the configuration in it, save and then double click it. You can add this file to Windows autostart if needed.

Configuration

There are two variables that affect the script. The first one brokenKeys is mandatory to be set to fit your scenario. The second one fixOffset is optional:

Line 8: brokenKeys Set this variable so in the quotes there are only your broken keys listed.

Line 16: fixOffset You can leave as is or just to fit your requirements for auto repeat requirements (read comments in code).

Links

Problem with this keyboard is discussed on various forums. https://www.reddit.com/r/LogitechG/comments/b8pqj9/g910_double_typing/ https://www.reddit.com/r/LogitechG/comments/fstryp/g910_keyboard_keys_double_typing/ https://www.reddit.com/r/LogitechG/comments/cu1uaa/ghub_causing_random_keypresses_or_ghostkey/

Other possible solutions

Above links suggest also other possible solutions (none worked for me, hence the script above).

  • Take your keys out and clean you keybard connections,
  • Change USB socket to which the keyboard is connected
  • Type your broken key like crazy for several minute until it fixes itself (some folks suggested it cleans the rust)
  • Quit or uninstall G-Hub
  • Go to Control Panel > Keyboard and change Repeat delay to longer one. Also can try to change slower Repeat rate.
;What does this script do?
;It's a workaround for broken G910 Logitech keyboards (possibly other keyboards too) whereby some keys occasionally register multiple keystrokes for one kkkkkeypress.
;The key bug appears because keyboard registers multiple keystrokes in a very short timespan even though you pressed the key only once.
;This script makes it so the subsequent keystrokes registered in a very short timespan are ignored thus outputing the key only for the first stroke.
;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 := "gf"
;timepan in which subsequent keystrokes should be ignored.
;In a typical scenario you yourself won't be pressing a single key faster than 5 times a second (every 200 miliseconds) so it's safe to have this number at 200.
;However, this number also determines how fast autorepeat can happen (when you hold the key).
;The smaller the number the faster the auto repeat speed of the fixed keys will be but also the higher the chance of the key bug happening when you type normally.
;Values higher than 80 seems work best but it might depend on you operating system.
fixOffset := 80
;That's it. There is no need to change anything else below
;These are typical values for a starter AHK script
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;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
@excessnet
Copy link

excessnet commented Jan 29, 2024

Please be advised a permanent solution has been found if cleaning doesn't do the trick: Percussive maintenance. Just hit the key lots of times, aggressively and fast, for about 30 seconds. Vary between short taps to powerful pushes to long presses. After 30 seconds of beatings, test it. Works like a charm for me. You only have to do this once, if you find the issue isn't solved contact Logitech and ask for a refund or get a new keyboard.

I'm surprised, but this worked for me... everytime find a new key that does that, I just hit it "hard" for some seconds and usually it's fixed. Thanks!

@BrendanBetheldo
Copy link

Will this clash with games and be seen as using cheating software?

@Yusseiin
Copy link

Will this clash with games and be seen as using cheating software?

You will disable this before playing any games or you won’t be able to keep a key pressed. (Sorry for bad eng )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment