Feasibility of adapting Nick's serial_no_block for key pads

I really like using Nick Gammon’s serial_no_block routine however I was wondering on the feasibility of adapting it for use with an i2c wired 4x3 keypad. In the code section shown below for example, the terminating case’n’: would need to be changed to accept another key as an enter button, say #.

Thoughts?

void processIncomingByte (const byte inByte)
  {
  static char input_line [MAX_INPUT];
  static unsigned int input_pos = 0;

  switch (inByte)
    {
      
    case 'n':   // end of text
      input_line [input_pos] = 0;  // terminating null byte
      
      // terminator reached! process input_line here ...
      process_data (input_line);
      
      // reset buffer for next time
      input_pos = 0;  
      break;

    case 'r':   // discard carriage return
      break;

    default:
      // keep adding if not full ... allow for terminating null byte
      if (input_pos < (MAX_INPUT - 1))
        input_line [input_pos++] = inByte;
      break;

    }  // end of switch
   
  } // end of processIncomingByte

Did you try changing “case ‘\n’:” to “case ‘#’:”?

I plan to try that, just waiting on a port expander to arrive to wire up the keypad. I'm thinking its not going to be so simple as that though.