while ($cmd = ReadKey(0)){ if ($cmd =~ /K/){ #fork and do something, continue with loop } #check for other keys either forking more or killing procs etc }