Usecase: One Shot macro (tutorial)

Edit (Karel):
Please note that these days, one shot can be created easily via oneShot holdKey LS (for modifier - left shift in this case) or oneShot holdLayer mod (for layer - mod in this case).

The ifGesture method is deprecated and strongly not recommended.

Nevertheless thanks, for your contribution @kriker97!

Hi everybody:

I want to share a macro that I wrote in order to get the one shot funcionality on my UHK.

First of all, we need to know what is a one shot key, according to QMK documentation:
“One shot keys are keys that remain active until the next key is pressed, and then are released. This allows you to type keyboard combinations without pressing more than one key at a time. These keys are usually called “Sticky keys” or “Dead keys”.”

You can check more in this link: QMK Firmware - One Shot Keys

Looking for a way to implement this functionality, I found in the Extended macro engine’s documentation, the sentence ifGesture.

With this sentence, I want achieve the following: when I pressed the Shift key, this should turn the Shift key hold on, for when I press any alphanumeric key, I will be able to get a uppercase letter or the special character of the key that I’ll press next, and the Shift key will turn off after that. For example, when the global mode is Caps off, and I pressed the Shift key on a first step (with the oneshot macro), and then the “a” key, I want to get “A”. Another example, when I press shift key, and after the “1” key, I should get the character “!” in the English - USA Dvorak - layout.

First of all, we need to get the id key that we need to pass, like the key we need to press in order to complete the funcionality. To accomplisht this task we need use


And asign it to a key. I have this on the Right Clic on the Key cluster module.

In order to obtain the key id to put it into the ifGesture command, we need to press the key with the resolveNextKeyId, and next, to press the key that I want to find its id.

Finally, to get the one shot funcionality, I created a macro with the next code:

ifGesture 029 final tapKey enter //One Shot Key + Space = enter
ifGesture 027 final tapKey RS-f22//One Shot Key + Space = enter
ifGesture 085 final tapKey LS //One Shot Key + Space =  leftShift
ifGesture 065 final tapKey LS-1 //One Shot Key + 1 =  leftShift + 1
ifGesture 066 final tapKey LS-2 //OSK + 2 =  leftShift + 2
ifGesture 067 final tapKey LS-3 //OSK + 3 =  leftShift + 3
ifGesture 068 final tapKey LS-4 //OSK + 4 =  leftShift + 4 
ifGesture 069 final tapKey LS-5 //OSK + 5 =  leftShift + 5
ifGesture 070 final tapKey LS-6 //OSK + 6 =  leftShift + 6
ifGesture 079 final tapKey LS-a //OSK + a =  leftShift + a
ifGesture 080 final tapKey LS-o //OSK + 8 =  leftShift + o
ifGesture 081 final tapKey LS-e 
ifGesture 082 final tapKey LS-u 
ifGesture 084 final tapKey LS-i 
ifGesture 072 final tapKey LS-openingBracketAndOpeningBrace 
ifGesture 073 final tapKey LS-commaAndLessThanSign
ifGesture 074 final tapKey LS-dotAndGreaterThanSign 
ifGesture 075 final tapKey LS-p
ifGesture 077 final tapKey LS-y
ifGesture 087 final tapKey LS-semicolonAndColon
ifGesture 088 final tapKey LS-q
ifGesture 089 final tapKey LS-j
ifGesture 090 final tapKey LS-k
ifGesture 091 final tapKey LS-x 
ifGesture 00 final tapKey LS-7
ifGesture 01 final tapKey LS-8
ifGesture 02 final tapKey LS-9
ifGesture 03 final tapKey LS-0
ifGesture 004 final tapKey LS-minusAndUnderscore 
ifGesture 005 final tapKey LS-closingBracketAndClosingBrace
ifGesture 014 final tapKey LS-f
ifGesture 007 final tapKey LS-g
ifGesture 008 final tapKey LS-c
ifGesture 009 final tapKey LS-h
ifGesture 010 final tapKey LS-l
ifGesture 011 final tapKey LS-openingBracketAndOpeningBrace  
ifGesture 012 final tapKey LS-equalAndPlus 
ifGesture 013 final tapKey LS-backslashAndPipeIso 
ifGesture 021 final tapKey LS-d
ifGesture 015 final tapKey LS-r
ifGesture 016 final tapKey LS-t
ifGesture 017 final tapKey LS-n
ifGesture 018 final tapKey LS-s
ifGesture 019 final tapKey LS-slashAndQuestionMark  
ifGesture 022 final tapKey LS-b
ifGesture 023 final tapKey LS-m
ifGesture 024 final tapKey LS-w
ifGesture 025 final tapKey LS-v
ifGesture 026 final tapKey LS-z

I have a Dvorak configuration, so, you should change these numbers to get this in other configuration.

And last but not at least, I assigned the macro to the Mod key:

I hope this post will be of help.

1 Like

Also, since the next firmware release it will be possible to simply oneShot holdKey LS.

1 Like

Thanks for sharing.

haha, today seems to be one-shot day. So actually there are already two shots. :wink:

1 Like

That’s great news, I use a lot this macro, is more comfortable to me in my daily basis. I’m really looking forward to using this new feature.

What version firmware has this? Or will have this please?

oneShot modifier will be in the next one released, that is probably 9.4.0…