$key IS PgUp or PgDn (see Term::ReadKey), which means that value is not usable, BUT ord($key) will give you the ascii value (an integer), hex this decimal and that value can be used in regex with \x -- except in this case PgUp and PgDn have the same value to \x (7e)