public void run() {
    currentScreenView.init();
    while (true) {
      try {
        KeyPress keyPress = terminal.pollKeyPress();

        ScreenView nextScreenView;
        if (keyPress != null) {
          // Dispatch the key press to the current screen
          nextScreenView = currentScreenView.handleKeyPress(keyPress);
        } else {
          if (timerTimestamp != null) {
            long now = EnvironmentEdgeManager.currentTime();
            if (timerTimestamp <= now) {
              // Dispatch the timer to the current screen
              timerTimestamp = null;
              nextScreenView = currentScreenView.handleTimer();
            } else {
              TimeUnit.MILLISECONDS
                .sleep(Math.min(timerTimestamp - now, SLEEP_TIMEOUT_MILLISECONDS));
              continue;
            }
          } else {
            TimeUnit.MILLISECONDS.sleep(SLEEP_TIMEOUT_MILLISECONDS);
            continue;
          }
        }

        // If the next screen is null, then exit
        if (nextScreenView == null) {
          return;
        }

        // If the next screen is not the previous, then go to the next screen
        if (nextScreenView != currentScreenView) {
          currentScreenView = nextScreenView;
          currentScreenView.init();
        }
      } catch (Exception e) {
        LOGGER.error("Caught an exception", e);
      }
    }
  }
This dispatches key presses and timers to the current {@link ScreenView}.
hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/Screen.java