def read_char
      input = $stdin.getch
      return input unless input == "\e"
      begin
        Timeout.timeout(0.01) do
          input += $stdin.getch
          input += $stdin.getch
        end
      rescue Timeout::Error
        # ignored
      end
      input
    end
def read_char
      input = $stdin.getch
      return input unless input == "\e"
      begin
        Timeout.timeout(0.01) do
          input += $stdin.getch
          input += $stdin.getch
        end
      rescue Timeout::Error
        # ignored
      end
      input
    end
Reads keypresses from the user including 2 and 3 escape character sequences.