The silly thing is that I have commands that do exactly that for the exact same reason, but didn't think of that technique here
Well spotted, iceblast
If you need to have the ability to hold down the key(s), you'd want to use loops, E.G.
Begin Text Compare : [{ACTIVEWINDOWPROCESSNAME}] Equals 'EliteDangerous64'
Press down Up key
Start Loop While : Keyboard Key '1' Is Pressed
End Loop
Release Up key
Else
Press down 1 key
Start Loop While : Keyboard Key '1' Is Pressed
End Loop
Release 1 key
End Condition
(using the "Condition Else" action or checking the "When this block is reached, exit command if condition is met" option in the "End a Conditional Block" action is functionally identical in this case; Use whichever is most visually clear to you)
As you mentioned need to be able to toggle this on and off ingame, instead of checking the process name you'd want to use a variable, E.G.
Begin Boolean Compare : [hotkeysEnabled] Equals False
Press down 1 key
Start Loop While : Keyboard Key '1' Is Pressed
End Loop
Release 1 key
Else
Press down Up key
Start Loop While : Keyboard Key '1' Is Pressed
End Loop
Release Up key
End Condition
(check the "Evaluate 'Not Set' as false" option)
[enable;disable] hotkeysBegin Text Compare : [{CMD}] Contains 'enable'
Set Boolean [hotkeysEnabled] to True
Else
Set Boolean [hotkeysEnabled] to False
End Condition
Note that the main limitation of this technique is that keys pressed by software do not cause character repeats, meaning when you hold down the "1" key, it will only type a single "1" character, rather than many of them after a short delay.