Keypad input stored as variable

Hello everyone,
How would I write a code that allowed me to input a number (for example "30") that I pressed on my 4x4 keypad and then that number would be stored as a variable?

Ultimately the final goal of my project is for the serial monitor to print "Set Speed" and then i could input a number (less than 255) from my keypad and have that number set the speed of the motor I am using.

I know how to initialize the keypad and define everything, but from then on I am stuck! Any help would be great, thanks guys!

How would I write a code that allowed me to input a number (for example "30") that I pressed on my 4x4 keypad and then that number would be stored as a variable?

Look closely at your question. See the spaces between words? See the question mark at the end? Those things are important. How will you know that "30" is not just the start of "300" or "3018" or "30128"?

The answer to that last question will define what you do. Storing each character in an array, with a NULL terminator, and then using atoi() is easy. Knowing when to call atoi() and store the result is the issue.