Get if shortcut was used recently?

I have an action button shortcut which dynamically changes depending on your surroundings, but somethings I’d like it to do something else. Is there a way to see if the shortcut was used recently, and if yes, program to do something else?