Skip to content

Instantly share code, notes, and snippets.

@QuietNoise
Last active March 7, 2024 11:34
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
@gashtal
Copy link

gashtal commented Oct 17, 2022

I found this script trying to find a solution for my G513 double typing. I just tried to use it, but it seems it doesn't work fine for languages other than English. As soon as I type any of the "broken" keys in Word when typing in a language other than English, that key somehow gets typed is English instead of the language I am actually typing in, and the font also changes. Anybody has any idea how this can be fixed?

@QuietNoise
Copy link
Author

What's language you typing in?

@gashtal
Copy link

gashtal commented Oct 18, 2022

@QuietNoise The issue was caused by Send %pressedKey% in line 50 in the original script. Replacing it with Send {%pressedKey%} as is done in your second script resolved the issue. Thank you for this script. :)

@Dransed
Copy link

Dransed commented Oct 18, 2022

This works just fine, thank you! I'm using it on my g513 carbon
My only issue came with the capital letters. If I set it as "ao" I'm not able to write with capital a or capital o. :(

@gashtal
Copy link

gashtal commented Oct 19, 2022

@Dransed Try what I mentioned in my message right above yours. Should solve your problem. Or use the updated code from PatWong99.

@Dransed
Copy link

Dransed commented Oct 19, 2022

@gashtal I tried but it didn't work :/

@Dransed
Copy link

Dransed commented Oct 25, 2022

Update.

At the end I bought an air duster and a bottle of pure isopropyl alcohol. Taked away all the keycaps, turned the keyboard upside down, shaked it like a MF, then clean it with a brush, after that with cotton buds putted a little of alcohol inside the switches and blow it a little with the air duster, putted some more of alcohol and I let it dry.

So far so good but it's a shame that I have to do this ritual like every two or three months.

@darksageaura
Copy link

darksageaura commented Nov 2, 2022

This is working for me but is there a way to add the arrow keys? I'm using the script from PatWong and the keypad numbers.

Figured it out.

@jollyjones61
Copy link

jollyjones61 commented Dec 7, 2022

when i type in Backspace it doesn't effect the Backspace key instead it effects the "B" key putting in in caps?

brokenKeys := "q|d|Backspace"

Is what I typed.

I think I got it thanks:)

@corthreat
Copy link

corthreat commented Dec 11, 2022

Hi @jollyjones61 - my line looks like this: brokenKeys := "g|Space|a" and it causes "S" to be in caps and space still going amock.
What did you do to fix your B and make Backspace work??

@jollyjones61
Copy link

@corthreat I deleted the previous code and replaced it with this:

;List all your broken keys
brokenKeys := "g|f|Space|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

;Assign a hotkey handler for each broken key
Loop, Parse, brokenKeys, |
{
keyName :=
Hotkey, $%A_LoopField%, HotKeyHandler
}

Return

HotKeyHandler:
pressedKey := SubStr(A_ThisHotKey,2)
sinceLastPress := A_TickCount - lastTimePressed[pressedKey]
if (sinceLastPress > fixOffset) {
lastTimePressed[pressedKey] := A_TickCount
Send {%pressedKey%}
}
return

@Drekonai
Copy link

Drekonai commented Dec 20, 2022

Thank you very much for this fix, I got so annoyed from constantly typing with double ee's!!

@corthreat
Copy link

corthreat commented Dec 21, 2022

@jollyjones61 thanks for the script it works mostly now. However, now I can only type the lowercase letter. If I was writing all caps and "e" was the letter in the script, it would look like this: WHOLe.

@Dom-Luck
Copy link

Great, is there a way to just quickly add the whole keyboard? seems like it would make things more consistent and less repetititve.

@InsaneAwesomeTony
Copy link

it worked!
changing the type speed from 80 to 150 made it better tbh
but i'm still gonna have to get a new since this fix fixes my S key and makes me unable to use it while gaming. but it is what it is. the fault lies at Logitech for being stinky with their keyboards

@Drekonai
Copy link

I LOVED Logitech, until they introduced their new software and using the g910. I also got myself a new keyboard, and I'm really in love with both the soft- and hardware for the Corsair K70 RGB PRO keyboard.

@Woserite
Copy link

While this has been working really well to fix the typing issues, I've been having issues in games. Using WASD for movement doesn't seem to respond at all in any configuration that I'd tried with the offset.

@johntor
Copy link

johntor commented Apr 15, 2023

Do we have a version for AutoHotkey v2?

@Woserite
Copy link

Do we have a version for AutoHotkey v2?
I was getting errors that it required v1
image

@QuietNoise
Copy link
Author

QuietNoise commented Apr 16, 2023

@johntor

Do we have a version for AutoHotkey v2?

No version for Autohokey v2. AHK v2 was released year after I've made this gist.
Having said that AHK 1 and 2 can run on the same machine without conflict. It runs as such on my computer and documentation confirms the same: https://www.autohotkey.com/v2/

@Woserite

While this has been working really well to fix the typing issues, I've been having issues in games. Using WASD for movement doesn't seem to respond at all in any configuration that I'd tried with the offset.

@InsaneAwesomeTony

it worked! changing the type speed from 80 to 150 made it better tbh but i'm still gonna have to get a new since this fix fixes my S key and makes me unable to use it while gaming. but it is what it is. the fault lies at Logitech for being stinky with their keyboards

This script is no good for super fast typing and keypresses required for gaming because its main purpose it to slow repetitions and whacking WSAD like crazy will be registered as the glitch this script is meant to fight.

@Dom-Luck

Great, is there a way to just quickly add the whole keyboard? seems like it would make things more consistent and less repetititve.

You can just add all the keys in the settings.


I no longer have this keyboard to make any sensible tests and in general I won't be maintaining this code as it's no longer relevant to me personally (unless my new keyboard will start going crazy in the same way :P) but I see some forks and good comments you guys and girls can build improvements on.

@johntor
Copy link

johntor commented Apr 16, 2023

I no longer have this keyboard to make any sensible tests and in general I won't be maintaining this code as it's no longer relevant to me personally (unless my new keyboard will start going crazy in the same way :P) but I see some forks and good comments you guys and girls can build improvements on.

@QuietNoise Which is your new keyboard after G910?

@QuietNoise
Copy link
Author

QuietNoise commented Apr 16, 2023

@QuietNoise Which is your new keyboard after G910?

G915. Switched to bluetooth as I need hop between devices and offices quite often. This made it very easy.
Added benefit is that it has 2 wireless modes (bluetooth and lightspeeed dongle) so it's good for gaming and for working on 3 computers at the same time.

It's not perfect, backlight doesn't lit the secondary characters. Terrible and very uncomfortable design decision from their part as you can't see these characters in darker environments.

And yeah, it's still logitech but I like my G keys a lot haha :D

@johntor
Copy link

johntor commented Apr 17, 2023

Thank you for your comments! I'm looking for the G815 which is the same but wired version. I didn't notice the symbol lightning is so bad... but you are right. After a driver update my G910 is working fine again so I think is a bit software related. My problem is with G5 that I use as Paste.
During the last year there was an update that brought my problem back so I used your solution for a few days and then on the next update the problem was gone... So I'm still on G910... waiting for the next failure to get my next one!!!

Thank you again! Take Care!

J!

@kellenvu
Copy link

kellenvu commented May 11, 2023

Here's my modified version that allows for CAPSLOCK and key modifiers (e.g. Alt, Shift).

/*
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, e.g. if your broken keys are i, v, and Right, then the line below shoud be 
; brokenKeys := "i|v|Right"
brokenKeys := "i|v|Right"

/*
Timespan in which subsequent keystrokes should be ignored, in ms.
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 := 120

; 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
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
}

; Assign a hotkey handler for each broken key
Loop, Parse, brokenKeys, |
{
    Hotkey, $*%A_LoopField%, HotKeyHandler 
}

HotKeyHandler:
    keyName := SubStr(A_ThisHotKey, 3)
    shift := GetKeyState("Shift", "P")
    capsLock := GetKeyState("CapsLock", "T")
    ctrl := GetKeyState("Ctrl", "P")
    alt := GetKeyState("Alt", "P")
    win := GetKeyState("LWin", "P") || GetKeyState("RWin", "P")
    if(capsLock) {
        shift := !shift
    }
    sendCmd := (shift ? "+" : "") . (ctrl ? "^" : "") . (alt ? "!" : "") . (win ? "#" : "") . "{" . keyName . "}"
    sinceLastPress := A_TickCount - lastTimePressed[keyName]
    if(sinceLastPress > fixOffset) { ; Send the hijacked key only when sufficient time has passed
        lastTimePressed[keyName] := A_TickCount
        ; MsgBox, % "cmd " sendCmd
        Send %sendCmd%
    }
return

@YoavGoldhorn
Copy link

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.

@MohamedZazou
Copy link

MohamedZazou commented Nov 20, 2023

thanks for this fix it's work perfectly on my G910 Orion Spectrum (add the game key like zqsd aerf because of logitech sell depreciated keyboards)

Edit : But i need to disable the script when im playing. So, it's usefull for worrking but not playing. Really need a new keyboard :(

@Yusseiin
Copy link

I have add all keys and some specials and seems working fine :) Thanks a lot
brokenKeys := "q|w|e|r|t|y|u|i|o|p|a|s|d|f|g|h|j|k|l|z|x|c|v|b|n|m|Numpad0|Numpad1|Numpad2|Numpad3|Numpad4|Numpad5|Numpad6|Numpad7|Numpad8|Numpad9|Delete|Space|Enter|Up|Down|Left|Right"

@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