Converting char to int on arduino keypad

I don't wanna have to convert everything like this, is there an easier way

void loop(){
char customKey = customKeypad.getKey();
if (customKey && pressed == 0) {
if (customKey == '1') {
ck = 1;
}
if (customKey == '2') {
ck = 2;
}
if (customKey == '3') {
ck = 3;
}
if (customKey == '4') {
ck = 4;
}
if (customKey == '5') {
ck = 5;
}
if (customKey == '6') {
ck = 6;
}
if (customKey == '7') {
ck = 7;
}
if (customKey == '8') {
ck = 8;
}
if (customKey == '9') {
ck = 9;
}
if (customKey == 'A') {
testAdd += 1;
}
if (customKey == '#') {
testEqual += 1;
}
if (customKey == 'D') {
testAdd = 0;
testEqual = 0;
digit1 = 0;
digit2 = 0;
digit3 = 0;
}
pressed += 1;
}

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Please post your full sketch, using code tags when you do

Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

It is also helpful to post error messages in code tags as it makes it easier to scroll through them and copy them for examination

Most people subtract 30 from the key value to get the number.

If you have chars in the keypad array then deleting '0' from the character that you read will turn it into an integer with the appropriate value

For numbers, subtract '0' from customKey. ck = customKey - '0';.

Hex 30...

Use a switch case contruction:

switch (customKey) {
case '1':
  value = 1;
case '#':
  value = "desired 1";
case 'D':
  value = "desired 2";
.
.
.
.
}

You could also consider taking the radical approach and actually put the numerals in the keypad array as bytes rather than chars

I'm not sure what you mean. Perhaps relevant is that getKey() returns 0 to signify the absence of a key press.

a7

Arduino Cookbook, 2nd edition, page 101. Cost less than $6 on EBAY and free postage. Well worth the money.

What I had in mind was declaring the array that holds the values returned by the keypad as byte rather than char

Whether that meets the requirements of @cael_m depends on what he/she wants to do