The very first thing you should do is look into getting the Term::ReadKey extension from CPAN. It now even has limited support for closed, proprietary (read: not open systems, not POSIX, not Unix, etc) systems.

You should also check out the Frequently Asked Questions list in comp.unix.* for things like this: the answer is essentially the same. It's very system dependent. Here's one solution that works on BSD systems: