Listing 2. Loop and monitor for key presses.

  while(!key[KEY_ESC]){//loop until user presses Esc key

    clear_keybuf();//clear old stuff from the buffer