Prevent specific key on keyboard from double clicking

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
RobbyG10
Posts: 1
Joined: 27 Jan 2023, 10:31

Prevent specific key on keyboard from double clicking

Post by RobbyG10 » 27 Jan 2023, 10:36

Hi, I am new to autohotkey and have done some searching on how to do this, but I have only found solutions for mouse clicks. What I need is to prevent a keyboard key from double clicking too fast, i.e. if the same button is registered twice or more times in a period less than say 200 milliseconds for it to only register 1 button press.

I have something like this, but I am sure I am missing something basic.

Code: Select all

2::	
	If (A_TimeSincePriorHotkey < 150) ;hyperclick
		Return
	send {2 down}
	KeyWait, 2
	send {2 up}
Return

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

Re: Prevent specific key on keyboard from double clicking

Post by mikeyww » 27 Jan 2023, 12:06

Welcome to this AutoHotkey forum!

Code: Select all

#Requires AutoHotkey v2.0
$2::Send A_PriorHotkey != A_ThisHotkey || A_TimeSincePriorHotkey > 150 ? 2 : ""

Post Reply

Return to “Ask for Help (v1)”