if ($key eq "~") { # it's a tilde } elsif ($key eq "\e[5~") { # pgup } elsif ($key eq "\e[6~") { # pgdown }