Qukeys with more states

Maybe this is a terrible idea. I’m trying to create a sort of universal modifier key that I can use to access multiple shortcuts - which have different modifiers. Let’s call the key [magic]. I currently have it programmed using qukeys, such that the primary key is space, and the secondary key is control.

  • [magic] → space
  • [magic]+[other key] → ctrl-[other key]

I want to also cram task-switcher functionality in there, in other words

  • [magic] → space
  • [magic]+tab → alt+tab
  • [magic]+[any other key] → ctrl-[other key]

The kicker is that since this is the task switcher, it’s not sufficient to use a macro or magic-combo to just emit an “alt-tab” key event – the alt key has to look like it stays down, so I can push [magic]+tab+tab+tab to cycle through applications.

Any ideas how such a thing might be accomplished?

It seems a little similar to how qukeys works in that it buffers up the event and then decides what to do based on a subsequent event, only the result of the quantum key doesn’t just depend on whether another key was pressed, it also depends which key.