Need help with replacing keys

Ask gaming related questions
Alphalazer
Posts: 3
Joined: 09 Mar 2023, 11:45

Need help with replacing keys

Post by Alphalazer » 09 Mar 2023, 11:49

Never used AHK before in my life and no idea how to use it but I've managed to get a script up and running, however what I am trying to do with it is not working.
The script is very simple:
"

Code: Select all

#Requires AutoHotkey v2.0

F8::Suspend

w::up
a::left
s::down
d::right
return
"
[Mod edit: [code][/code] tags added.]
I want to replace wasd with arrows so I can play an old RTS game using wasd. However the issue is whenever I press multiple keys at the same time eg. W and A to go diag, when I release them one of the keys "stick", or won't turn off until I press it again. Gamebreaking. Any ideas on how to fix?

Rohwedder
Posts: 7732
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Need help with replacing keys

Post by Rohwedder » 10 Mar 2023, 10:33

Hallo,
only a try:

Code: Select all

#Requires AutoHotkey v2.0
Keys := {w:"up",a:"left",s:"down",d:"right"}
SetTimer WASD, 100
Return
WASD() {
For v, k in Keys.OwnProps()
	IF !GetKeyState(v,"P") And GetKeyState(k)
		Send "{" v " Up}{" k " Up}"
}
F8::Suspend
w::up
a::left
s::down
d::right

Alphalazer
Posts: 3
Joined: 09 Mar 2023, 11:45

Re: Need help with replacing keys

Post by Alphalazer » 10 Mar 2023, 20:38

still sticks. Thanks for the reply tho

User avatar
mikeyww
Posts: 27216
Joined: 09 Sep 2014, 18:38

Re: Need help with replacing keys

Post by mikeyww » 10 Mar 2023, 22:11

Code: Select all

#Requires AutoHotkey v2.0
w::
a::
s::
d:: {
 Static move := Map('w', 'Up', 'a', 'Left', 's', 'Down', 'd', 'Right')
 SetKeyDelay 30
 While GetKeyState(ThisHotkey, 'P')
  For letter, direction in move
   GetKeyState(letter, 'P') && SendEvent('{' direction '}')
}

Alphalazer
Posts: 3
Joined: 09 Mar 2023, 11:45

Re: Need help with replacing keys

Post by Alphalazer » 10 Mar 2023, 22:19

this makes it not work at all. Sorry for all of your troubles but thankyou again

User avatar
mikeyww
Posts: 27216
Joined: 09 Sep 2014, 18:38

Re: Need help with replacing keys

Post by mikeyww » 10 Mar 2023, 22:40

Does it work in Notepad?

Post Reply

Return to “Gaming”