I’m trying to replicate a feature called “Snap Tap” found in Razer keyboards, which is similar to the Null Movement/Null Bind function. I found an existing AutoHotkey (likely AHK v1) script that perfectly replicates this function, but I want the script to operate at a lower system level to minimize latency.
Without SnapTap mode, pressing two opposite directional keys simultaneously can cause the game to interpret it as a command to stop moving, requiring the player to release one of the keys to register a new direction. However, with SnapTap mode enabled, when you press two opposite directional keys simultaneously, such as “A” and “D,” the keyboard prioritizes the last key pressed. This means that if you press “A” to move left and then press “D” to move right without releasing “A,” the keyboard will only register the last key pressed, which is “D.” This allows your character to instantly change direction to the right without stopping, even though both keys are being pressed at the same time.
Interception API: My first attempt was using the Interception API to replicate this action. Unfortunately, it resulted in numerous bugs, likely due to my own errors.
Keyboard Hook: My next approach involved creating a Keyboard Hook. I almost succeeded, but it had persistent bugs after performing specific sequences of actions.
AutoHotInterception: I discovered the AutoHotInterception library, which gave me renewed hope. Returning to Interception, I made several attempts, but my lack of programming experience became increasingly apparent.
Despite these setbacks, I haven’t given up. I’m reaching out for help to get this working. Below is the original Null Movement.ahk script in case anyone can assist me in adapting it.
#SingleInstance
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , A
; Null Movement Script
; This updates the A and D keys so that only one is held down at a time
; This avoids the situation where game engines treat holding both strafe keys as not moving
; Insead holding both strafe keys will cause you to move in the direction of the last one that was pressed
a_held := 0 ; Variable that stores the actual keyboard state of the a key
d_held := 0 ; Variable that stores the actual keyboard state of the d key
a_scrip := 0 ; Variable that stores the state of the a key output from the script
d_scrip := 0 ; Variable that stores the state of the d key output from the script
*$a:: ; Every time the a key is pressed, * to include occurences with modifiers (shift, control, alt, etc)
a_held := 1 ; Track the actual state of the keyboard key
if (d_scrip){
d_scrip := 0
Send {Blind}{d up} ; Release the d key if it's held down, {Blind} so it includes any key modifiers (shift primarily)
}
if (!a_scrip){
a_scrip := 1
Send {Blind}{a down} ; Send the a down key
}
return
*$a up:: ; Every time the a key is released
a_held := 0
if (a_scrip){
a_scrip := 0
Send {Blind}{a up} ; Send the a up key
}
if (d_held AND !d_scrip){
d_scrip := 1
Send {Blind}{d down} ; Send the d down key if it's held
}
return
*$d:: ; Every time the d key is pressed
d_held := 1
if (a_scrip){
a_scrip := 0
Send {Blind}{a up}
}
if (!d_scrip){
d_scrip := 1
Send {Blind}{d down}
}
return
*$d up:: ; Every time the d key is released
d_held := 0
if (d_scrip){
d_scrip := 0
Send {Blind}{d up}
}
if (a_held AND !a_scrip){
a_scrip := 1
Send {Blind}{a down}
}
return
vini_seboldp is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.