(I didn't read the code, I could be all wet here) I think what he wants is:
Key #1 behavior:
On press does Alt-down, Tab-down, Tab-up (and Alt is still down)
... on release does Alt-up
On tap does Alt-down, Tab-down, Tab-up, Alt up
Key #2: Normal Tab key behavior.
-----
Use:
Key #1-Down and release generates Alt-Tab down and Tab-Alt up == Switch to next app (using a single tap)
Key #1-Down, Key #2 tap, Key #2 tap, Key #1-up == Switch to next app + 2 (with a hold and 2 taps.)
Unusual, perhaps, but it you swap between the 2 front-most apps a lot it would add efficiency, while not eliminating the ability to get to other apps.