Page 1 of 1

Prevent double pressing while keeping constant pressing

Posted: 17 Dec 2017, 19:44
by hiurt
When I press the space bar in my keyboard, sometimes it will input the space character twice. I got a script from AutoHotkey's subreddit that fixed my problem, though now nothing happens if I press the space bar constantly. The script is:

Code: Select all

$Space::
    If (A_TimeSincePriorHotkey>100 OR A_TimeSincePriorHotkey=-1)
        Send {Space}
Return
I have tried changing it to

Code: Select all

$Space::
    If (A_TimeSincePriorHotkey>100 OR A_TimeSincePriorHotkey=-1 OR A_TimeSincePriorHotkey<40)
        Send {Space}
Return
It did fix it... kind of. When typing something, it now responds to constant pressing, but in games and in https://www.microsoft.com/appliedscienc ... gDemo.aspx, pressing the space bar (even if not constantly) does nothing unless ctrl or shift is being held. I honestly have no clue why this happens.

Is it possible to create a script that blocks double spaces while allowing pressing constantly (without having to press Ctrl or Shift too)? If so, what do I have to change/add/remove to the code above?

Thank you in advance!

Re: Prevent double pressing while keeping constant pressing

Posted: 18 Dec 2017, 02:37
by Rohwedder
Hallo,
try:

Code: Select all

$Space::
	Send {Space Down}
	Sleep, 100
	SetKeyDelay,10,10
	While GetKeyState("Space","P")
		Send {Space Down}
	Send {Space Up}
Return