Temporarily Change 'D' to 'Delete' with 'Alt+Tab' Sequence Without Affecting 'Alt+D

For context, in Windows, you can press Alt+Tab and hold Alt to close many windows and applications by pressing Delete.

How can I create a macro on my UHK so that pressing Alt and then Tab, and continuing to hold Alt, changes the function of the D key to Delete? The D key should revert to its normal function when Alt is released.

I want to avoid creating an Alt layer that maps D to delete because A) there is no quick way to copy the base layer mapping to another layer (you can only duplicate a keymap); B) I want to preserve the original Alt+D for other applications (meaning I don’t want Alt+D to become Alt+Delete all the time).

Thanks! I’ve tried loading the reference doc into GPT-4 to help me write such a script, but it failed. It would be neat if there was a fine-tuned model specific to the UHK smart macro language one day!

1 Like

You can rebind actions dynamically using set keymapAction....

I think binding your alt to this macro should work:

pressKey iLA
ifShortcut noConsume tab set keymapAction.base.d keystroke delete
delayUntilRelease
set keymapAction.base.d keystroke d
releaseKey LA

See firmware/doc-dev/user-guide.md at master · UltimateHackingKeyboard/firmware · GitHub and firmware/doc-dev/reference-manual.md at master · UltimateHackingKeyboard/firmware · GitHub for more details

Thank you for your help but I get a compile error.

What is your firmware version?

Ah, I see the problem. It will be fixed soon. In the meanwhile, please use:

pressKey iLA
ifShortcut noConsume tab set keymapAction.base.81 keystroke delete
delayUntilRelease
set keymapAction.base.81 keystroke d
releaseKey LA
2 Likes

Thanks! That worked. Now I can delete all my explorer windows with one hand, something I could not dream of on any other keyboard.

2 Likes

Just released Agent 4.1.0, which includes many improvements. It also bundles the newly released firmware 11.1.0, which contains the fix. Current Agent installations should auto-update themselves and the firmware.

Thanks, I confirmed that d works in place of 81. With that, I was able to get help with GPT4-Turbo to refine the query to change my JKLI cluster to temporarily map to arrow keys. What a boost in ergonomics when I constantly alt-tab between a bunch of screens and delete. Here’s an update version:

pressKey iLA
ifShortcut noConsume tab {
    // Temporarily rebind keys to new actions
    set keymapAction.base.d keystroke delete
    set keymapAction.base.j keystroke left
    set keymapAction.base.k keystroke down
    set keymapAction.base.l keystroke right
    set keymapAction.base.i keystroke up
}
delayUntilRelease

// Restore keys to their original actions
set keymapAction.base.d keystroke d
set keymapAction.base.j keystroke j
set keymapAction.base.k keystroke k
set keymapAction.base.l keystroke l
set keymapAction.base.i keystroke i
releaseKey LA

It may not be perfect, but providing the user guide and reference along with a few examples helps GPT4 (Turbo edition, I believe, which has a longer context window) answer some basic queries. In my case, I was not sure how to execute multiple commands (rebind more than one key) and it accurately predicted the refined script. I think this sort of tool would help a lot of folks who are not so savvy with UHK smart macro programming language get more value. GPT4-Turbo also helped me build some other scripts or explain existing scripts so I better understand the syntax.

Big thank you again to kareltucek !

1 Like

We’ve tried using GPTs with moderate success before. Maybe we should retry if it’s of use.

1 Like