# Virtual Keypad Made and Read in the same sketch

**URL:** https://discourse.processing.org/t/virtual-keypad-made-and-read-in-the-same-sketch/29290
**Category:** Coding Questions
**Created:** [April 12, 2021, 12:27am UTC](https://discourse.processing.org/t/virtual-keypad-made-and-read-in-the-same-sketch/29290 "2021-04-12T00:27:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![edgee](https://avatars.discourse-cdn.com/v4/letter/e/c57346/32.png) [@edgee](https://discourse.processing.org/u/edgee)
#### Post date: [April 12, 2021, 12:27am UTC](https://discourse.processing.org/t/virtual-keypad-made-and-read-in-the-same-sketch/29290/1 "2021-04-12T00:27:46Z")

</div>

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

---

<div class="post-metadata">

### Author: ![edgee](https://avatars.discourse-cdn.com/v4/letter/e/c57346/32.png) [@edgee](https://discourse.processing.org/u/edgee)
#### Post date: [April 12, 2021, 1:03am UTC](https://discourse.processing.org/t/virtual-keypad-made-and-read-in-the-same-sketch/29290/2 "2021-04-12T01:03:44Z")

</div>

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.
