invalid use of non-static member function for keyboard.begin

Hello, so I recently did a school project about a touch-sensitive music controller (that’s what I would like to call it) I wrote some code for it, and it worked. Then I didn’t use it for about 1 year. In that time, I accidentally deleted the code. Now I have rewritten it, but I get this error ( invalid use of non-static member function for keyboard.begin
) on the line where ( Keyboard.begin() ) is and I really don’t know what’s wrong with the code. I’m pretty new to coding and don’t have much knowledge. Any help would be appreciated. Also if I could get a reply ASAP that would be great. I kinda need the code.

The full code is attached below.

// Import the CapacitiveSensor Library.
// Import the Keyboard library.
#include <CapacitiveSensor.h>
#include <Keyboard.h>


// Set the Send Pin & Receive Pin.
CapacitiveSensor cs_2_3 = CapacitiveSensor(2, 3);       // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
CapacitiveSensor cs_2_4 = CapacitiveSensor(2, 4);       // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil
CapacitiveSensor cs_2_5 = CapacitiveSensor(2, 5);       // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
/*CapacitiveSensor   cs_0_4 = CapacitiveSensor(0,6);    // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
  CapacitiveSensor   cs_0_5 = CapacitiveSensor(0,7);    // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
  CapacitiveSensor   cs_0_6 = CapacitiveSensor(0,8);    // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
  CapacitiveSensor   cs_2_9 = CapacitiveSensor(2,9);*/  // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil


void setup() {
  // Arduino start communicate with computer.
  Serial.begin(9600);
  
  // Defines a threshold 
  long threshold = int(500);

    Keyboard.begin;
}


void loop()
{
  // Set the sensitivity of the sensors.
  long start = millis();
  long TS1 = cs_2_3.capacitiveSensor(10);
  long TS2 = cs_2_4.capacitiveSensor(10);
  long TS3 = cs_2_5.capacitiveSensor(10);
  /* long Sensor4 =  cs_2_6.capacitiveSensor(60);
    long total5 =  cs_2_7.capacitiveSensor(60);
    long total6 =  cs_2_8.capacitiveSensor(60);
    long total7 =  cs_2_9.capacitiveSensor(60);*/

// Print out sensor values in console
  Serial.print(millis() - start);
  Serial.print (TS1);
  Serial.print ('\n');
  Serial.print (TS2);
  Serial.print ('\n');
  Serial.print (TS3);
  Serial.print ('\n');


  /*seriel.print (Ts4);
    seriel.print ('\n');
    seriel.print (Ts1);
    seriel.print ('\n');
    seriel.print (Ts1)
    seriel.print ('\n')
    seriel.print (Ts1)
    seriel.print (s'\n')*/
  delay(10);



// if the value given by the sensor > than threshold, print out a string

  if (TS1 > "threshold");
  {
    Keyboard.write('e');
    delay(300);
  }

  if (TS2 > "threshold");
  {
    Keyboard.write('r');
    delay(300);
  }


  if (TS3 > "threshold");
  {
    Keyboard.write('t');
    delay(300);
  }

  Keyboard.end();

}

TSMC_sketch_2.ino (2.39 KB)

You're missing the function call brackets here:

    Keyboard.begin;
  // Defines a threshold
  long threshold = int(500);

That code is useless. The int() part is useless. The variable will go out of scope before it is used, so the whole statement is useless.

 if (TS1 > "threshold");

How can the value in TS1 be reasonably compared to a string?

   Keyboard.begin;

This is NOT calling the begin() method.

oh wow…i’m stupid. Tnx for quick reply

so Pauls. What if I did

long threshold = 500;

instead and

  if (TS1 > threshold);
  {
    Keyboard.write('e');
    delay(300);
  }

NIbba_John8:
so Pauls. What if I did ... instead and ...

Whether that works, or not, depends on where you define the variable. If you define it in setup(), you can't use it in loop().

If you define it as a global variable, you can use it in loop().

By the way, the ; on the end of the if statement does not belong there.

ohk, I just made it work. Thank you so much for the guidance. I'm very noob at coding. I only know basic python. Not C# or whatever code Arduino uses.