AltGr fast press to ESC remap

Put simple Tips and Tricks that are not entire Tutorials in this forum
wis
Posts: 1
Joined: 22 Dec 2022, 12:51
Contact:

AltGr fast press to ESC remap

Post by wis » 22 Dec 2022, 13:11

I thought this would be easier, it was complicated by the fact that AltGr is really two keys pressed together, Left Ctrl and Right Alt,
I thought it was just Right Alt, I made sure that 1. AltGr key still works as expected, when pressed with other keys, it outputs accent characters,
and 2. when AltGr is pressed for a long time (more than 150 milliseconds) it doesn't send an ESC press

Code: Select all

time := -1

~LControl & ~RAlt::
	if (time = -1)
		time := A_TickCount
return
~LControl & ~RAlt Up::
	var := A_TickCount - time
	if (instr(A_PriorKey, "RAlt") || instr(A_PriorKey, "LCtrl")) && var <= 150
		send {esc}
	time := -1
return
Thanks to RHCP and everybody for this thread for publishing what was my starting code on the old forum

vmech
Posts: 356
Joined: 25 Aug 2019, 13:03

Re: AltGr fast press to ESC remap

Post by vmech » 22 Dec 2022, 17:36

Due to short-circuit evaluation would much better to swap && evaluations:

Code: Select all

if var <= 150 && (instr(A_PriorKey, "RAlt") || instr(A_PriorKey, "LCtrl"))
Please post your script code inside [code] ... [/code] block. Thank you.

Post Reply

Return to “Tips and Tricks (v1)”