Hello friends, I appreciate any help.
My keyboard has an issue that when I press W and D at the same time, E is pressed by a ghost! For example, if I press WD my keyboard will type WDE. It is also very annoying in games (while driving a car, if you try to turn right you will jump out of the car!)
What code can I use to ignore the E key while I am pressing W and D at the same time?
how to ignore the ghost key? Topic is solved
Re: how to ignore the ghost key?
simplest idea comes to mind is
e as defined hotkey which is disabled as input key without any modifiers. Ever tried that?
Code: Select all
e::
Re: how to ignore the ghost key?
I think keyboard ghosting, actually being a keyboard-specific hardware problem, has its own quirks. I can't reproduce it here, but I would try smth like:
(return stands here for the return statement which you would put at the end of a subroutine or function; you could also put it into the next line(s).)
Like this, e should only be disabled if w and d are pressed at the same time. Otherwise, the e key should still be usable as itself.
If the game runs elevated, your script would need these rights as well.
I would advise against simply using e:: since this would only disable e without side-effects, if absolutely no other code - or if smth like return or exit which ends the subroutine - follows. It also wouldn't be context-sensitive which seems to be requested here.
Consider
Code: Select all
#If GetKeyState("w", "P") && GetKeyState("d", "P") ; check if w and d are currently pressed
e::return ; disable e
#If
Like this, e should only be disabled if w and d are pressed at the same time. Otherwise, the e key should still be usable as itself.
If the game runs elevated, your script would need these rights as well.
I would advise against simply using e:: since this would only disable e without side-effects, if absolutely no other code - or if smth like return or exit which ends the subroutine - follows. It also wouldn't be context-sensitive which seems to be requested here.
Consider
Spoiler
Last edited by gregster on 05 Aug 2023, 16:33, edited 1 time in total.
Reason: spoilered code
Reason: spoilered code
Re: how to ignore the ghost key?
My first thought was also it's a hardware problem so what to do.
If computer really recognizes the pressed E key you could remap E to be W+D pressed via autohotkey. Since I don't have any keyboards with these problems I cannot test anything. Only problem in any case... you cannot use your E key
I just tried my cheapest 8€ keyboard and it does not do it >.>
If computer really recognizes the pressed E key you could remap E to be W+D pressed via autohotkey. Since I don't have any keyboards with these problems I cannot test anything. Only problem in any case... you cannot use your E key
I just tried my cheapest 8€ keyboard and it does not do it >.>
Re: how to ignore the ghost key?
Dear @gregster and @Master_X, thank you for your reply.
This code doesn't work for me:
this one e:: works but I cannot use E anymore.
Is there another code to convert WDE to WD, or disable E while I am holding W?
(When I hold WD, my keyboard thinks I am holding WDE physically, so you can test your code by holding WDE)
This code doesn't work for me:
Code: Select all
#If GetKeyState("w", "P") && GetKeyState("d", "P") ; check if w and d are currently pressed
e::return ; disable e
#If
Is there another code to convert WDE to WD, or disable E while I am holding W?
(When I hold WD, my keyboard thinks I am holding WDE physically, so you can test your code by holding WDE)
Re: how to ignore the ghost key?
Tbh, I would buy another keyboard but thats me.
disable e by holding w would be
Since it's a hardware thing, you cannot convert the input in any way. As far I understand the keyboard key w+d gives the computer the e input like if you press e. So you can only handle the pressed E OR the pressed W key OR the pressed D key. But I am also by no means good in this. I may be wrong
disable e by holding w would be
Code: Select all
#If GetKeyState("w", "P")
e::return
#If
Re: how to ignore the ghost key? Topic is solved
Your keyboard still sends e while pressing both w and d ?Bootimar wrote: ↑06 Aug 2023, 01:22This code doesn't work for me:Code: Select all
#If GetKeyState("w", "P") && GetKeyState("d", "P") ; check if w and d are currently pressed e::return ; disable e #If
Just to make sure: Which AHK version are you running?
I am assuming that you are running some recent AHK v1.1.x version. Correct?
If e:: "worked" to completely deactivate e, this single line should as well (just without potential side-effects) in both v1 and v2:
Code: Select all
e::return ; disable e
No, unfortunately this won't work on my keyboard. If I am already holding w and d, e will never fire when I press it as a third key. That's another hardware limitation of many keyboards: Many three-key combos not consisting of modifiers won't work together. (I would need a different (gaming) keyboard.)(When I hold WD, my keyboard thinks I am holding WDE physically, so you can test your code by holding WDE)
What I can test: Hold w or d, then press e. Not sure if it will help you for the game, but this works for me (I replaced && with ||)
Code: Select all
; #InstallKeybdHook
#Requires AutoHotkey v1.1.33 ; require minimum version
#If GetKeyState("w", "P") || GetKeyState("d", "P") ; check if w or d are currently pressed
e::return ; disable e
#If
You could also add #InstallKeybdHook at the top and see if that helps somehow.
No idea if this can be solved at all with AHK.
Re: how to ignore the ghost key?
Thank you very very much dear @gregster and also @Master_X ! You revived my keyboard!
This code perfectly works on any version of AHK:
This code perfectly works on any version of AHK:
Code: Select all
; #InstallKeybdHook
#If GetKeyState("w", "P") || GetKeyState("d", "P") ; check if w or d are currently pressed
e::return ; disable e
#If
Who is online
Users browsing this forum: Kintaro-OEx, Marium0505, Trunks298 and 170 guests