I think this is what you are talking about in Target, this snippet is using the awesome 128 button library from here for the ALT Hold 3 position toggle on the Warthog throttle
Pulse+ makes the button press momentary (so it ends in Open rather than close) when going to the on position, and MAPKEYR sends the keystroke (again Momentary) on the Off or centering move. I use it to move between A2A and A2G mode, with the centering toggle turning the modes off (i.e. a second press)
MapKey(&Throttle, APPAT, PULSE+DX44);
MapKeyR(&Throttle, APPAT, PULSE+DX44);
MapKey(&Throttle, APAH, PULSE+DX45);
MapKey(&Throttle, APALT, PULSE+DX46);
MapKeyR(&Throttle, APALT,PULSE+DX46);