USB Keyboard formatting - shift button

Hi, I wanted to create a keyboard using the Keyboard library, I'm having some trouble creating uppercase letters, I wanted it so that when a button is held down it would function as a shift button.

So far I had the idea of adding 22 to the character value, however the formatting of this is wrong and I can't seem to find out the right way to format it.

So far I have something like this:

#include <Keyboard.h>

char ctrlKey = KEY_LEFT_CTRL;  

void setup() {
  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  // initialize control over the keyboard:
  Keyboard.begin();
}

void loop() {
  
if (digitalRead(2) == LOW) {
  delay(500);
  Keyboard.write(66);
  delay(100);
  Keyboard.releaseAll();
}

if (digitalRead(3) == LOW)
  delay(200);
  char +22
  delay(100);
  Keyboard.releaseAll();
}

Any help would be much appreciated

that should be -22, not +22 sorry

What is a line like

  char +22

supposed to do? The compiler does not like it.

sterretje:
What is a line like

  char +22

supposed to do? The compiler does not like it.

Ah yes sorry I should've mentioned I'm new to programming. That line is the problem when a button is pressed I want it to alter the character by subtracting 22 so that the any new presses would be uppercase.

If there is another way to do I'd be happy to do it that but I can't find one online

OK, that could be something like

void loop()
{
  int key = digitalRead(2);
  int shift = digitalRead(3);

  char keyToSend;

  if (key == LOW)
  {
    keyToSend = 66;
  }

  if(shift == LOW)
  {
    keyToSend -= 22;
  }

  Keyboard.write(keyToSend);
  delay(100);
  Keyboard.releasAll();
}
#include <Keyboard.h>

void setup() {
  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
  Keyboard.begin();
}

void loop()
{
  int key = digitalRead(2);
  int shift = digitalRead(3);
  int a = digitalRead(4);
  
  char keyToSend;

  if (key == LOW)
  {
    keyToSend = 66;
  }

  if(a == LOW)
  {
    keyToSend = 65;
  }

  if(shift == LOW)
  {
    keyToSend -= 22;
  }

  Keyboard.write(keyToSend);
  delay(100);
  Keyboard.releaseAll();
}

I tried the above and it's just printing endless streams of b's, any advice?

any advice?

Post a schematic. Before trying to use pin data, you should make sure that the pins are doing what you expect.

Search for an ASCII table. The code for 'B' is 66 decimal but the code for 'b' is 98 decimal. To convert 'b' to 'B' subtract 32.