0
votes

My Esc key is broken on my keyboard, and I would like to remap it to Alt+` (that's Alt and ` grave accent, same button as the ~ tilde). However:

!`::Esc

will trigger Alt+Esc when pressed (!Esc) because the Alt key is held down. How do I remap Alt+` so that, when pressed, it will trigger Esc rather than Alt+Esc?

EDIT: I am not opposed to using an entirely different program to remap my keys. I just want to remap ALT+` to the Esc key in all of my Windows.

3
Not sure about your specific problem, but in case you don't find a solution: please see autohotkey.com/docs/misc/Remap.htm#Remarks , it says "When a script is launched, each remapping is translated into a pair of hotkeys ..." You could copy that piece of code and adjust it to your needs.phil294

3 Answers

1
votes

Use SendPlay:

!`::sendplay {Esc}

SendPlay [...] buffers any physical keyboard or mouse activity during the send, which prevents the user's keystrokes from being interspersed with those being sent.

1
votes

I found two possible ways to achieve this.


Use BlockInput

Disables or enables the user's ability to interact with the computer via keyboard and mouse.

!p::
    BlockInput On
    send {Esc}
    BlockInput, Off
return

You might need to run the script as administrator and the alt and/or p may get stuck down, which led me to the second solution.


Use KeyWait

Waits for a key or mouse/joystick button to be released or pressed down.

!p::
    KeyWait, Alt
    send {Esc}
return
-1
votes

This should work:

!`::
    SendInput, {Alt Up}{Esc}
Return