Macro to swap actionbar, but only when holding the button

I know about /swapactionbar 1 2, but is there a way for a macro to display actionbar 2 while the key is held down, then swap back to actionbar 1 as soon as the key is released?