Exiting a function on a key press.

  int d1;
  int d2;
  
  {
    d2 = time % 10;
    d1 = int(time/10);
  }

The curly braces are useless. There is no good reason to separate the declaration from the initialization.

  if (time = 0)

Assigning a value to time in an if statement hardly seems like a good idea.

The return statement is not strictly needed. A return will happen when the end of the function is reached. But, it doesn't hurt anything.