Triggering a loop???

Is there a way to trigger a loop by hitting a key then stop the loop by hitting the same key?