Using time as a variable

Hi.
I need to create an experiment: a stimulus is displayed for 10 seconds, and after that the participant must click either the right arrow key or the left one. If they click the right, the stimulus will be displayed 2 seconds longer (so 12), if they click left, then 2 seconds shorter (so 8). This repeats for 20 trials. Is this possible to do? I’m struggling to find any tutorial or question related to using time as a variable.

You can set the duration to a variable, e.g. displayTime, set it to 10 in Begin Experiment and add or subtract 2 in End Routine based on the value of key_resp.keys