The UHK has always been useful for gaming, but as we keep enhancing it with new features, it’s becoming a formidable weapon in the hands of gamers.
As a casual gamer, I want to share some of the things I’ve been doing with my UHK to improve my gaming experience.
Double-Tap Weapon Selection
Every once in a while, I slay demons in Doom Eternal, and I have always found it challenging to pick the exact weapon I want to use. My left hand is always on the WASD cluster, and my right hand is always on the mouse.
The numbers 1 to 8, highlighted in red, are mapped to weapons. Even when using the UHK in merged mode (the two halves connected together), the distance between the WASD cluster and 8 is far too large, so it makes sense to map all the weapons to numbers 1 to 4.
Let’s leave 1 to 4 unmodified when single-tapped, but when double-tapped, let’s make these keys emit 5 to 8. To implement this for key 1, I use the following smart macro:
ifDoubletap final tapKey 5 // double-tap: super shotgun
tapKey 1 // single-tap: combat shotgun
(To create a smart macro in Agent, you have to create a macro, click on the "Add macro action" button, and select "Command".)
Parameterized Macros
The above macro works great, and I could copy-paste it and modify the numbers for the other keys, but there’s a better way by using parameterized macros:
ifDoubletap final tapKey ¯oArg.2 // double-tap
tapKey ¯oArg.1 // single-tap
Now we can reuse this macro for the other number keys by simply changing the arguments.
Lazy Double-Tap
Our macro is excellent for first-person shooters because as soon as you hit the key, the weapon is immediately selected, and when you hit the key again, the other weapon is selected.
But this behavior is unwanted in MOBAs and MMORPGs, where you often want to choose between two related actions without accidentally triggering the first one. For example:
- Single-tap: Cast a healing spell on your targeted ally
- Double-tap: Self-cast the same healing spell
For such a behavior, we can use the following macro:
ifGesture timeoutIn 200 $thisKeyId final tapKey ¯oArg.2 // double-tap
tapKey ¯oArg.1 // single-tap
This macro will not emit the single-tap character when double-tapping the key, only when the timeout has elapsed.
Keymap Inheritance
When creating a new keymap, it’s tempting to start with your default keymap, such as the "QWERTY for PC" keymap, and override the desired keys. But this way, you won’t be able to easily tell which keys were overridden in your new keymap.
Even worse, when having to change the default keymap, you’ll have to override all the keymaps in which you relied on the default keymap. There’s a better way: keymap inheritance.
Instead of starting with a default keymap, start with an empty keymap and inherit from a base keymap. This way, you can override the desired keys in your new keymap and leave the rest blank.
Let’s say your base keymap is the "QWERTY for PC keymap", which has the "QWR" abbreviation.
Now, create a blank keymap and let’s name it "Doom Eternal" with the "DOE" abbreviation. To inherit from the "QWERTY for PC" keymap, create the following smart macro in Agent:
replaceKeymap QWR
overlayKeymap current
This smart macro has a special name of $onKeymapChange DOE, making it a macro event that is automatically executed when switching to the Doom Eternal keymap.
- The
replaceKeymap QWRcommand replaces the current keymap with the "QWERTY for PC" keymap. - Then the
overlayKeymap currentcommand overlays the nonempty keys of the "Doom Eternal" keymap on top of the "QWERTY for PC" keymap.
You can go crazy and create multilevel inheritance this way, such as using a base keymap, creating a descendant Gaming keymap, and then creating a descendant "Doom Eternal" keymap on top of the Gaming keymap.
If you want to delve into the world of smart macros, check out its user guide and reference manual.
That’s It for Now
I hope this article has given you some ideas on how to use your UHK to improve your gaming experience or just organize your keymaps better.
We’re excited to share more about the power of macro-related features in future articles, as there’s so much more you can do with them.
Talk to you soon!