actually it does not work very well.
\W means match non-word character, opposite of
\w. See
http://perldoc.perl.org/perlre.html. You may want to look at
http://search.cpan.org/~jstowe/TermReadKey-2.30/ReadKey.pm too. There may be other models on CPAN that may do what you are looking for. So search CPAN. Or most likely another monk will have the right answer.