What if instead you put all keypresses to an array and pop from that into the command sequence?
_________________________
He was a good little monkey and always very curious...