Page 1 of 1

Remapping CTRL + h as backspace

Posted: 22 May 2019, 02:58
by huberoliver
I have remapped Capslock as CTRL. I am also trying to use CTRL + h as backspace, i.e., deleting the first token left to the current cursor position:

Capslock::Ctrl

^h::
send {BS}
return

Using the actual CTRL keys in combination with the h key does the job: If I hold the CTRL key and press the key, one token gets deleted to the left. The same is true for pressing and holding Capslock and the h key. HOWEVER: Trying to delete more than one token to the left is easy with the actual CTRL key: I simply keep the CTRL key pressed and press the h key as many times as tokens I want to delete. This does not work with the remapped Capslock key though. In this key, I have to release the Capslock key each time I want to use the h key to delete I token. If I do not do that (i.e., if I just keep the Capslock key pressed), the letter "h" gets printed to the screen.

Any chance I could make the remapping of the Capslock key "persistent"?

Re: Remapping CTRL + h as backspace

Posted: 22 May 2019, 03:50
by elModo7
Try this:

Code: Select all

:X:^h::DoBackSpace()

DoBackSpace(){
    while(GetKeyState("LControl","H"))
    {
        Send {BS}
        Sleep 50
    }
}

Re: Remapping CTRL + h as backspace

Posted: 22 May 2019, 05:31
by huberoliver
This did unfortunately not solve the issue. Using your code, pressing Capslock and H does not have any effect anymore.

Re: Remapping CTRL + h as backspace  Topic is solved

Posted: 22 May 2019, 16:09
by Sam_
huberoliver wrote:
22 May 2019, 02:58
I have remapped Capslock as CTRL. I am also trying to use CTRL + h as backspace, i.e., deleting the first token left to the current cursor position:

Capslock::Ctrl

^h::
send {BS}
return

Using the actual CTRL keys in combination with the h key does the job: If I hold the CTRL key and press the key, one token gets deleted to the left. The same is true for pressing and holding Capslock and the h key. HOWEVER: Trying to delete more than one token to the left is easy with the actual CTRL key: I simply keep the CTRL key pressed and press the h key as many times as tokens I want to delete. This does not work with the remapped Capslock key though. In this key, I have to release the Capslock key each time I want to use the h key to delete I token. If I do not do that (i.e., if I just keep the Capslock key pressed), the letter "h" gets printed to the screen.

Any chance I could make the remapping of the Capslock key "persistent"?
I was unable to reproduce your results. I tried your code as well as

Code: Select all

Capslock::LCtrl
^h::Send,{Backspace}
and

Code: Select all

#InstallKeybdHook
Capslock::LCtrl
^h::Send,{Backspace}
Both seem to be working as you want. Maybe make sure you are using the latest version of AHK. There have been a few bug fixes concerning hotkeys and hotstrings in the near past.

Re: Remapping CTRL + h as backspace

Posted: 23 May 2019, 01:36
by huberoliver
Bugger - the upgrade from 1.0x to the latest version solved the issue. Should have done that before wasting everybody's time. Thx for your support!

Re: Remapping CTRL + h as backspace

Posted: 08 Jan 2021, 03:53
by ranched
Sorry to revive an old thread but this is exactly what I was trying to accomplish and had to use another method. Posting here for others to find as well.
In my case ahk is installed on a remote session and I had to use the following to get it to work:

Code: Select all

; ctrl h as backspace 
^h::
KeyWait, Backspace
SendEvent {Backspace}
return
One more way to get that readline functionality everywhere.