Sending space on tap and control on long press

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kuehmaster
Posts: 3
Joined: 31 Aug 2022, 22:38

Sending space on tap and control on long press

Post by kuehmaster » 06 Oct 2022, 07:54

Hi,

I was looking at the space cadet shift script, and I was wondering if it was possible to do one with space and control.

For instance, when you tap the space bar, it sends space. However, when you hold it down, it sends control.

Thank you so much for your help!

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

Re: Sending space on tap and control on long press

Post by mikeyww » 06 Oct 2022, 09:36

Code: Select all

$Space::
KeyWait, Space, T.2
If ErrorLevel { ; Held
 on := True
 Send {Ctrl down}
 SoundBeep, 1500
} Else Send {Space}
Return
#If on
^Space::
KeyWait, Space
Send {Ctrl up}
SoundBeep, 1000
on := False
Return
#If

Post Reply

Return to “Ask for Help (v1)”