/r/MechanicalKeyboards Ask ANY question, get an answer sticky

The next section is for catch modifiers, but since I have not ctrl, esc, shift, or anything else on the "keyboard" I think I should comment it out, except the last else loop involves all the other types of keys so that might be important?

// Catch Modifiers
  if(keypress == 176){
    mod[j] = KEY_LEFT_CTRL;
  }
  else if(keypress == 177){
    mod[j] = KEY_LEFT_ALT;
  }
  else if(keypress == 178){
    mod[j] = KEY_LEFT_SHIFT;
  }
  else{
    key[i] = keypress;
  }

Here's the rest for brevity's sake.

// Hold keypresses in buffer
  Keyboard.set_modifier(mod[0]);
  Keyboard.set_key1(key[0]);
  Keyboard.set_key2(key[1]);
  Keyboard.set_key3(key[2]);
  Keyboard.set_key4(key[3]);
  Keyboard.set_key5(key[4]);
  Keyboard.set_key6(key[5]);
}

// This method sends the depressed keys and clears the buffer.
void sendKey(){
  Keyboard.send_now();
  for(int x = 0; x < 6; x++){ key[x] = 0; }
  for(int x = 0; x < 2; x++){ mod[x] = 0; }
  Keyboard.set_modifier(mod[0]);
  Keyboard.set_key1(key[0]);
  Keyboard.set_key2(key[1]);
  Keyboard.set_key3(key[2]);
  Keyboard.set_key4(key[3]);
  Keyboard.set_key5(key[4]);
  Keyboard.set_key6(key[5]);
}

void loop() {
  int keycount = 0;
  for (int c = 0; c < COLS; c++) {
    digitalWrite(col[c], HIGH);
    for (int r = 0; r < ROWS; r++) {
      if (digitalRead(row[r])){
          setKey(layout[r][c]);
      }
    }
    digitalWrite(col[c], LOW);
  }

  //Now that all of the keys have been polled it is time to send them out!
  sendKey();
  delay(15);

So I had an error on the "Keyboard.send_now()" command when I first complied it, but it was fixed when I switched the Tools>USB type to keyboard. There is an error log when I load the code that mentions unused commands, specifically "keycount". So I know I have extra code that's probably causing the problem, but I don't know what.

/r/MechanicalKeyboards Thread Parent