Virtual Keypad Made and Read in the same sketch

Hi,
I have a project that will have processing program running on an SBC with a touch panel. on one of the GUI screens, values need to be entered in a field. I created a numpad on the screen using ControlP5.
for the last two days I’ve searched and scratched my head. I cannot figure out how to make these numpad buttons duplicate physical keyboard number presses.
I can click on input field and enter value with keyboard, such as 255. but how do I do that from the virtual keypad that I made?

Any help would be appreciated.

Best,
Edge

Ok, most likely dumb way to go about it but,
declare an empty string. When a number button on the virtual pad is pressed, add the corresponding number to the string. for example if num1 is pressed:

String numpd = “”;
void numpd(){
numpd = numpd +1;
}
and so on with all numbers from 0-9. two buttons to hit, enter to save the string and convert it to int later and a button to cancel the input, leaving the string unchanged.
PITA I have two add lots more lines of code to a program that has about 1300 lines as it is. mostly due to repetitions.