Just need a script that sends the "Esc" key when I double tap the Spacebar
Just need a script that sends the "Esc" key when I double tap the Spacebar
My Google results when trying to search for other forum posts about this only come up with people asking for the opposite: pressing one key to send a double tap of another. So if anyone can help me with a simple script to send the Escape key when I double tap the Space bar that'd be excellent. Thank you!
Re: Just need a script that sends the "Esc" key when I double tap the Spacebar
example with 'morse' ( user @flyingDman )
https://www.autohotkey.com/board/topic/146902-typing-using-the-numpad-like-on-old-phones/
EDIT : small modified for test > send $ if use space twice, otherwise send space
https://www.autohotkey.com/board/topic/146902-typing-using-the-numpad-like-on-old-phones/
EDIT : small modified for test > send $ if use space twice, otherwise send space
Code: Select all
;- https://www.autohotkey.com/board/topic/146902-typing-using-the-numpad-like-on-old-phones/
#warn
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
$space::
p := Morse()
If (p = "1")
{
;msgbox, 262208,LONG-PRESS ,0-LONG PRESS,1 ;- longer press as timeout
send,{space}
}
If (p = "0")
{
;msgbox, 262208, ,1-times,1
send,{space}
}
If (p = "00")
{
;msgbox, 262208,SEND $ ,2-times,1
Send,{text}$
;Send,{ESC}
}
If (p = "000")
{
;msgbox, 262208, ,3-times,1
send,{space 3}
}
return
;------------
esc::exitapp
;------------
Morse(timeout = 200) { ;
tout := timeout/1000
key := RegExReplace(A_ThisHotKey,"[\*\~\$\#\+\!\^]")
pattern:=""
Loop {
t := A_TickCount
KeyWait %key%
Pattern .= A_TickCount-t > timeout
KeyWait %key%,DT%tout%
If (ErrorLevel)
Return Pattern
}
}
;============================================================
Last edited by garry on 27 Oct 2021, 08:47, edited 1 time in total.
Re: Just need a script that sends the "Esc" key when I double tap the Spacebar
Code: Select all
$Space::
KeyWait, Space, T0.2
If !(ErrorLevel)
{
Sleep, 300
If (A_PriorHotKey = "$Space Up") ; double tap
Send {Esc}
else ; single tap
Send {Space}
}
else ; press-and-hold
{
while GetKeyState("Space", "P")
Send {Space} ; sends Space continuously
}
return
$Space Up:: return
Last edited by GEV on 27 Oct 2021, 11:43, edited 1 time in total.
Re: Just need a script that sends the "Esc" key when I double tap the Spacebar
Perfect! Thank you both SO much, now that I've seen how it works I can start to experiment a little further. That's how I've been learning AHK (very slowly lol), just dissecting existing scripts and making them custom to my own needs. This was just the one time I couldn't find a similar script to Franken-script the pieces together lol.
Cheers!
Cheers!
Re: Just need a script that sends the "Esc" key when I double tap the Spacebar
@GEV , works fine, I've forget : > else send space ( if tap space once ) or if tap 3-times > then send 3 spaces
Who is online
Users browsing this forum: Google [Bot] and 331 guests