stop running script while infinte loop

Hi


i have an experiment which runs an infinite while loop and i want to have the option to stop it by pressing particular keyboard key (i.e Ctrl+q).


Is it possible to wait for a key and still running the loop?


Regards

Tal