hold modifier keys slightly longer

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
techmon
Posts: 54
Joined: 16 May 2017, 13:30

hold modifier keys slightly longer

15 Apr 2021, 14:36

Hi,

One of the apps I use, does not recognize common shortcuts, like Ctrl C, etc. if I press it too quickly.

Is there a way to make it so that any time Ctrl is used, that it will be slightly delayed on the "Up" action, maybe by 100ms or so?

However, it needs to happen for combo hotstrings (like Ctrl C, etc, rather than simply when Ctrl is pressed by itself)

Thanks,
Shawn
User avatar
boiler
Posts: 16911
Joined: 21 Dec 2014, 02:44

Re: hold modifier keys slightly longer

15 Apr 2021, 15:14

See if this helps:

Code: Select all

$Ctrl::
	Send, {Ctrl down}
	KeyWait, Ctrl
	Sleep, 100
	Send, {Ctrl up}
return
techmon
Posts: 54
Joined: 16 May 2017, 13:30

Re: hold modifier keys slightly longer

16 Apr 2021, 11:10

Thanks Boiler!

I tested it with Windows On-Screen keyboard %windir%\system32\osk.exe, and it works if just CTRL is pressed.

However, if Ctrl c or another shortcut with Ctrl + another key, it does not keep Ctrl pressed down.

Would you or anyone else have any other ideas?

Thanks again
User avatar
boiler
Posts: 16911
Joined: 21 Dec 2014, 02:44

Re: hold modifier keys slightly longer

16 Apr 2021, 11:53

This seems to work (delay of 1000ms so it's easier to see):

Code: Select all

$Ctrl::
	Send, {Ctrl down}
	KeyWait, Ctrl
	Sleep, 1000
	Send, {Ctrl up}
return

Ctrl Up::return
I don't think the OSK keyboard is a valid test because pressing another key seems to cancel the display of the Ctrl key even though a script like this running at the same time will indicate that it stays down as long as intended:

Code: Select all

loop {
	ToolTip % GetKeyState("Ctrl") ? "Down" : "Up"
	Sleep, 20
}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 202 guests