Search code examples
autohotkey

How can I remap Capslock+h as backspace using AutoHotkey?


If possible, in Windwows I want to remap Capslock+h as backspace, as emacs keybinding, using AutoHotkey.

How can I achieve this? I have found following example https://github.com/catweazle9/emacs-everywhere , which does not have keybinding for C-h.


Solution

  • AHK v1:

    Create an AHK script and add this code to it:

    #Requires AutoHotkey v1.1
    
    Capslock & h::Send {BS}
    
    • Save the file and double-click the file to run it.

    • Press Capslock+h to send backspace in the active window.

    To get familiar with AutoHotkey read the Beginner Tutorial.

    AHK v2:

    Create an AHK script and add this code to it:

    #Requires AutoHotkey v2.0
    
    Capslock & h::Send "{BS}"
    
    • Save the file and double-click the file to run it.

    • Press Capslock+h to send backspace in the active window.

    To get familiar with AutoHotkey read the Beginner Tutorial.

    EDIT:

    To this script you can add

    CapsLock & h::
      If is_target()
        Send %A_ThisHotkey%
      Else
        delete_backward_char()
      Return