Matrix keypad

How to function the '#' in a 4x4 matrix keypad into a 'Enter' button?

simplified pseudocode:

index = 0
while input != #
  {
  buffer[index] = input
  index = index + 1
  }

Can I do in this way?

case '#'
index = 0
while input != #
{
buffer[index] = input
index = index + 1
}
break;

What are we switching on there? IF it is input then please explain how it will be # to get into the case and then suddenly not be # for the while loop?

Because currently I have this keypad, LCD panel 16 x 2 and grove transmitter 315mHz. When I press '123A', I need to press '#' to able my transmitter to send its signal.

That was pseudocode I wrote, not C++. Just the elementary plan. You have to interpret and fill in the gaps using real code.

Thank for the response. However, I'm just a beginner in this. I don't know how to interpret and fill in the gaps from pseudocode to C++