think on one's feet
React quickly, be mentally agile, as in Reporters bombarded him with difficult questions, but Bill was very good at thinking on his feet. This expression uses on one's feet in the sense of “wide awake, alertly.” [First half of 1900s]
The American Heritage® Idioms Dictionary Copyright © 2002, 2001, 1995 by Houghton Mifflin Harcourt Publishing Company. Published by Houghton Mifflin Harcourt Publishing Company.