#include Adafruit_FreeTouch qt_0 = Adafruit_FreeTouch(A0, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE); #include void setup() { Keyboard.begin(); Serial.begin(115200); qt_0.begin(); } int qt_Threshold = 850; void loop() { int qt0 = 0; qt0 = qt_0.measure(); if (qt0 >= qt_Threshold) { Serial.print("qt0: "); Serial.println(qt0); Key2_act(); } //delay(100); } void Key2_act() { // shut down window Keyboard.press(KEY_LEFT_CTRL); Keyboard.write('w'); Keyboard.releaseAll(); KeyRelease(); } void KeyRelease() { Keyboard.releaseAll(); delay(500); digitalWrite(LED_BUILTIN, HIGH);// XIAO HIGH = Off } /*Example Keyboard.write('a'); //press and release 'a' key uint8_t Multiple[3]= {'1','2','3'}; Keyboard.write(Multiple,3); //multiple keys sequentially from a buffer Keyboard.print("456"); //print a string Keyboard.println("789"); //print another string with a line Keyboard.press(KEY_LEFT_SHIFT); //hold down the shift Keyboard.println("a uppercase sentence"); //this will be all caps Keyboard.release(KEY_LEFT_SHIFT);//release the shift Keyboard.println ("back to lowercase"); Keyboard.press(KEY_LEFT_SHIFT); //press shift Keyboard.println("1234"); //some text Keyboard.releaseAll(); //release all Keyboard.println("1234"); //not shifted Keyboard.print("A mistake"); //will attempt to erase this delay(1000); Keyboard.press(KEY_LEFT_CTRL); //will attempt control-z Keyboard.write('z'); Keyboard.releaseAll(); //release the control key */