Hi,
[PHP people - please don't kill me for answering this "off the topic" post.]
Being server-side, you have no hope of detecting client keypresses with perl alone.
You'll need to use a javascript "onkeypress" (use it in the <body> or a <link> tag .... I can't remember which gives best results). Then use the javascript to load your page with the perl function to stop the process.
If it is a seriously run-away process you're stopping, think carefuly about visitors without "onkeypress" javascript support.
An example "onkeypress" statement is:
<body onkeypress="javascript:alert('A key was pressed');">
Cheers,
Duncan.