Press a key, tap other keys, release first key to bracket with other sequences

On Kubuntu, I have a keyboard layout containing my favourite emoji. Since I write regularly in three scripts Latin, Devanagari and Tamil, inserting these script-neutral emoji means I have to:

  1. hit the shortcut to switch to that layout just for a few characters,
  2. type the few emoji
  3. hit the shortcut to go back to my previous layout.

I am thinking like pressing a Qukey or such, hitting the keys for the emoji, and releasing the first key which will automatically bracket the intervening keys with the shortcuts to go to and from the emoji layout…

Can anyone advise on how I would go about writing such a plugin?

I cannot use the Unicode plugin because there are issues with my WM not implementing the ISO standard for direct Unicode codepoint based input as said earlier here.

This seems like something a Compose key would be useful for.

Sorry I don’t understand. Can you clarify?

You should be able to configure your OS using a Compose Key, to which you can add custom sequences to produce the emoji that you want (if they’re not already present).