Page 1 of 1

AltGr fast press to ESC remap

Posted: 22 Dec 2022, 13:11
by wis
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

Re: AltGr fast press to ESC remap

Posted: 22 Dec 2022, 17:36
by vmech
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"))