How to map Ctrl-h to backspace

I want to use Ctrl-h as backspace but with the macro I tried, I get ctrl-backspace instead (deletes a whole word instead of one character in windows). Can someone help? This is what I’m trying:

// Assigned to h
ifCtrl {
    tapKey backspace
}
else {
    holdKey h
}
ifCtrl final suppressMods tapKey backspace
holdKey h

Also I think you actually want to use holdKey instead of the tapKey.

1 Like

Thanks! Could you please explain why final is needed here?

It makes the macro exit after the “modified command” (rest of the line) finishes.

It is just a shorthand and a historical way of writing things.

These days it could be also written as:

ifCtrl suppressMods tapKey backspace
else holdKey h

or

ifCtrl {
    suppressMods tapKey backspace
}
else {
    holdKey h
}

The reasons why I prefer the short final variant is that it is straightforward, cheap to evaluate, well tested, and without many potential pitfalls.

Especially braces are complex to evaluate and they allocate additional scope contexts, with great potential for problems, so seeing it used unnecessarily gives me the creeps :smiley:.

2 Likes

Excellent answer. Although…

without any potential pitfalls

My experience tells there’s always potential for that :smiley:

You could also do this without a macro by defining the h key on the Ctrl layer to send scancode Backspace. You will need to enable the Ctrl layer first; it can all be done in Agent. Leave the rest of the keys on the Ctrl layer undefined (“None”) so they keep their normal Ctrl+key behaviour.

3 Likes

fixed :upside_down_face: