Keyboard.h issue when mutiple keys are pressed.

Hello, I am trying to create a game controller with my Arduino Leonardo. It has 4 capacitive buttons but it also has some problems. One of them is holding multiple keys repeats keys instead of keeping them held down.
Pin 4 is connected to a line on a breadboard, to that line there are 4 1M resistors, each connected at the end to 4 pieces of aluminium foil and separate pins on the arduino (see code).
I am pretty sure this is a problem with either the keyboard library implementation itself or my implementation. Here is the code:

//#define ENCODER_SUPPORT

// Official Arduino libraries
#include <Keyboard.h>
#include <Mouse.h>
// 3rd party libraries. Make sure you have them!
#include <CapacitiveSensor.h>

// Button pins

// Send pin
#define BTAPINA 4

// Receive pins
#define BTAPINB 2
#define BTBPINB 6
#define BTCPINB 8
#define BTDPINB 10

// SWITCH
#define SWITCHPIN 13

// https://github.com/Kvathe/kappa-pad/blob/master/KappaPad/CapacitiveKey.h
class CapacitiveKey {
  public:
    CapacitiveSensor* sensor;
    bool keyReleased = true;
    char key;
    unsigned int releaseDelay = 20;
    unsigned int releaseTimer;
    unsigned int threshold;  
    int led;
    unsigned int sample;
    CapacitiveKey(uint8_t sendPin, uint8_t receivePin, unsigned int capacitiveThreshold, char keyboardKey)  {
      sensor = new CapacitiveSensor(sendPin, receivePin);
      threshold = capacitiveThreshold;
      key = keyboardKey;
    }
    ~CapacitiveKey() {
      delete sensor;
    }
    void keyUpdate(bool keyboardActive) {
      sample = sensor->capacitiveSensorRaw(1);
      if (sample > threshold) {
        if (keyReleased) {
          if (keyboardActive) Keyboard.press(key);
          keyReleased = false;
        }
        releaseTimer = releaseDelay;
      }
      else {
        if (!keyReleased) {
          if (releaseTimer == 0) {
            Keyboard.release(key);
            keyReleased = true;
          }
          else {
            releaseTimer--;
          }
        }
      }
    }
};

// Encoders

// Pin declarations
#ifdef ENCODER_SUPPORT

#define ENC_1_PIN_A 16
#define ENC_1_PIN_B 17
#define ENC_2_PIN_A 18
#define ENC_2_PIN_B 19

#endif

// Object declarations
#ifdef ENCODER_SUPPORT

Encoder encoder_left(ENC_1_PIN_A, ENC_1_PIN_B);
Encoder encoder_right(ENC_2_PIN_A, ENC_2_PIN_B);

#endif

#define SENSITIVITY 100

#define BTAKEY 'a'
#define BTBKEY 's'
#define BTCKEY 'k'
#define BTDKEY 'l'

CapacitiveKey btna = CapacitiveKey(BTAPINA, BTAPINB, SENSITIVITY, BTAKEY);
CapacitiveKey btnb = CapacitiveKey(BTAPINA, BTBPINB, SENSITIVITY, BTBKEY);
CapacitiveKey btnc = CapacitiveKey(BTAPINA, BTCPINB, SENSITIVITY, BTCKEY);
CapacitiveKey btnd = CapacitiveKey(BTAPINA, BTDPINB, SENSITIVITY, BTDKEY);

void
setup()
{
	pinMode(SWITCHPIN, OUTPUT);

	bool keyboardEnabled = digitalRead(SWITCHPIN);
	if (!keyboardEnabled) {
		// Setup mouse and keyboard
		Keyboard.begin();
		Mouse.begin();
	}

#if OUTPUT
	// We might print debug information later,
	Serial.begin(9600);
#endif
}

void
loop()
{
	check_key_events();

#ifdef ENCODER_SUPPORT
	encoder_func_left();
	encoder_func_right();
#endif
}

void
check_key_events()
{
	bool keyboardEnabled = digitalRead(SWITCHPIN);
	btna.keyUpdate(!keyboardEnabled);
	btnb.keyUpdate(!keyboardEnabled);
	btnc.keyUpdate(!keyboardEnabled);
	btnd.keyUpdate(!keyboardEnabled);
}

#ifdef ENCODER_SUPPORT

void
encoder_func_left()
{
	Mouse.move(encLeft.read(), 0, 0);
	encoder_right.write(0);
}

void
encoder_func_right()
{
	Mouse.move(0, encRight.read(), 0);
	encoder_right.write(0);
}

#endif

Is there a way to fix this issue? Also there's a small delay but I think that deserves a separate thread.

Keys are supposed to repeat if they are held down, this is normal behaviour for a keyboard. Were you expecting something else to happen?
I don't understand why you are trying to do here? You set the pin to be an output. Then you read it's status here and elsewhere in the code but you never write anything to it so you have no idea if it's high or low. That's going to result in some unpredictable behaviour. I suspect it should be an input.

	pinMode(SWITCHPIN, OUTPUT);
	bool keyboardEnabled = digitalRead(SWITCHPIN);

The code you've got here is very different to the github example. I suspect you've left out some important bits so suggest you get the example working properly before modifying it.

Not at all, from "both keys at the same time" I mean for a them to be pressed, not repeated. Also, I didn't see any example on Keyboard's press function.

Your code is doing the automatic repeat. Remove that code related to releaseTimer and see if that helps.

      if (sample > threshold) {
        if (keyReleased) {
          if (keyboardActive) Keyboard.press(key);
          keyReleased = false;
        }
        releaseTimer = releaseDelay;
      }
      else {
        if (!keyReleased) {
          if (releaseTimer == 0) {
            Keyboard.release(key);
            keyReleased = true;
          }
          else {
            releaseTimer--;
          }
        }
      }