Keyboard.press - Alternate between two characters - Same input

I have a toggle switch and when it's flicked down, I want it to press '/' and when it's up, I want it to press '#' for example. This is the relevant section of code.

   switchState_13 = digitalRead(SwitchPin_13);
   delay(50); // contact debounce
    if (switchState_13 != lastswitchState_13){
        Keyboard.press(pin_input_13);
        delay(50);
       Keyboard.release(pin_input_13);
    }

But when I include an "If" or "else" statement, it presses rapidly. Any ideas? Thanks

Post all of your code. For example, where is lastswitchState_13 set?

Also, what type of switch is it? Does it remain open when toggled?

Here's the code, sorry it's messy. This is the switch And what do you mean by "open?" Thanks.

///////////// Pin 1 ////////////////////
int switchState_1 = 0;         
int lastswitchState_1 = 0;
int SwitchPin_1 = 1;
char pin_input_1 = '1';
///////////// Pin 2 ////////////////////
int switchState_2 = 0;         
int lastswitchState_2 = 0;
int SwitchPin_2 = 2;
char pin_input_2 = 'A';
///////////// Pin 3 ////////////////////
int switchState_3 = 0;         
int lastswitchState_3 = 0;
int SwitchPin_3 = 3;
char pin_input_3 = 'B';
///////////// Pin 4 ////////////////////
int switchState_4 = 0;         
int lastswitchState_4 = 0;
int SwitchPin_4 = 4;
char pin_input_4 = 'C';
///////////// Pin 5 ////////////////////
int switchState_5 = 0;         
int lastswitchState_5 = 0;
int SwitchPin_5 = 5;
char pin_input_5 = 'D';
///////////// Pin 6 ////////////////////
int switchState_6 = 0;         
int lastswitchState_6 = 0;
int SwitchPin_6 = 6;
char pin_input_6 = 'E';
///////////// Pin 7 ////////////////////
int switchState_7 = 0;         
int lastswitchState_7 = 0;
int SwitchPin_7 = 7;
char pin_input_7 = 'F';
///////////// Pin 8 ////////////////////
int switchState_8 = 0;         
int lastswitchState_8 = 0;
int SwitchPin_8 = 8;
char pin_input_8 = 'i';
///////////// Pin 9 ////////////////////
int switchState_9 = 0;         
int lastswitchState_9 = 0;
int SwitchPin_9 = 9;
char pin_input_9 = '2';
///////////// Pin 10 ////////////////////
int switchState_10 = 0;         
int lastswitchState_10 = 0;
int SwitchPin_10 = 10;
char pin_input_10 = KEY_HOME;
///////////// Pin 11 ////////////////////
int switchState_11 = 0;         
int lastswitchState_11 = 0;
int SwitchPin_11 = 11;
char pin_input_11 = '/';
///////////// Pin 12 ////////////////////
int switchState_12 = 0;         
int lastswitchState_12 = 0;
int SwitchPin_12 = 12;
char pin_input_12 = ';';
///////////// Pin 13 ////////////////////
int switchState_13 = 0;         
int lastswitchState_13 = 0;
int SwitchPin_13 = 13;
char pin_input_13 = 'w';
char pin_input_13_2 = 'W';


//int switchState = 0;         
//int lastswitchState = 0;


void setup()
{
  pinMode(SwitchPin_1,INPUT_PULLUP);
  pinMode(SwitchPin_2,INPUT_PULLUP);
  pinMode(SwitchPin_3,INPUT_PULLUP);
  pinMode(SwitchPin_4,INPUT_PULLUP);
  pinMode(SwitchPin_5,INPUT_PULLUP);
  pinMode(SwitchPin_6,INPUT_PULLUP);
  pinMode(SwitchPin_7,INPUT_PULLUP);
  pinMode(SwitchPin_8,INPUT_PULLUP);
  pinMode(SwitchPin_9,INPUT_PULLUP);
  pinMode(SwitchPin_10,INPUT_PULLUP);
  pinMode(SwitchPin_11,INPUT_PULLUP);
  pinMode(SwitchPin_12,INPUT_PULLUP);
  pinMode(SwitchPin_13,INPUT_PULLUP);
  Keyboard.begin();
}

void loop()
{   
////////////////////// Pin 1 /////////////////////
   switchState_1 = digitalRead(SwitchPin_1);
   delay(50); // contact debounce
    if (switchState_1 != lastswitchState_1){
        Keyboard.print(pin_input_1);
      }
   lastswitchState_1 = switchState_1;
////////////////////// Pin 2 /////////////////////
   switchState_2 = digitalRead(SwitchPin_2);
   delay(50); // contact debounce
    if (switchState_2 != lastswitchState_2){
        Keyboard.print(pin_input_2);
      }
   lastswitchState_2 = switchState_2;
////////////////////// Pin 3 /////////////////////
   switchState_3 = digitalRead(SwitchPin_3);
   delay(50); // contact debounce
    if (switchState_3 != lastswitchState_3){
        Keyboard.print(pin_input_3);
      }
   lastswitchState_3 = switchState_3;
////////////////////// Pin 4 /////////////////////
   switchState_4 = digitalRead(SwitchPin_4);
   delay(50); // contact debounce
    if (switchState_4 != lastswitchState_4){
        Keyboard.print(pin_input_4);
      }
   lastswitchState_4 = switchState_4;
////////////////////// Pin 5 /////////////////////
   switchState_5 = digitalRead(SwitchPin_5);
   delay(50); // contact debounce
    if (switchState_5 != lastswitchState_5){
        Keyboard.print(pin_input_5);
      }
   lastswitchState_5 = switchState_5;
////////////////////// Pin 6 /////////////////////
   switchState_6 = digitalRead(SwitchPin_6);
   delay(50); // contact debounce
    if (switchState_6 != lastswitchState_6){
        Keyboard.print(pin_input_6);
      }
   lastswitchState_6 = switchState_6;
/////////////WWWWWWW///////// Pin 7 /////////////////////
   switchState_7 = digitalRead(SwitchPin_7);
   delay(50); // contact debounce
    if (switchState_7 != lastswitchState_7){
        Keyboard.print(pin_input_7);
      }
   lastswitchState_7 = switchState_7;
////////////////////// Pin 8 /////////////////////
   switchState_8 = digitalRead(SwitchPin_8);
   delay(50); // contact debounce
    if (switchState_8 != lastswitchState_8){
        Keyboard.print(pin_input_8);
      }
   lastswitchState_8 = switchState_8;
////////////////////// Pin 9 /////////////////////
   switchState_9 = digitalRead(SwitchPin_9);
   delay(50); // contact debounce
    if (switchState_9 != lastswitchState_9){
        Keyboard.print(pin_input_9);
      }
   lastswitchState_9 = switchState_9;
////////////////////// Pin 10 /////////////////////
   switchState_10 = digitalRead(SwitchPin_10);
   delay(50); // contact debounce
    if (switchState_10 != lastswitchState_10){
        Keyboard.print(pin_input_10);
      }
   lastswitchState_10 = switchState_10;
////////////////////// Pin 11 /////////////////////
   switchState_11 = digitalRead(SwitchPin_11);
   delay(50); // contact debounce
    if (switchState_11 != lastswitchState_11){
        Keyboard.print(pin_input_11);
      }
   lastswitchState_11 = switchState_11;   
////////////////////// Pin 12 /////////////////////
   switchState_12 = digitalRead(SwitchPin_12);
   delay(50); // contact debounce
    if (switchState_12 != lastswitchState_12){
        Keyboard.press(pin_input_12);
        delay(10);
        Keyboard.release(pin_input_12);
      }
   lastswitchState_12 = switchState_12;       
////////////////////// Pin 13 /////////////////////
   switchState_13 = digitalRead(SwitchPin_13);
   delay(50); // contact debounce
    if (switchState_13 != lastswitchState_13){
        Keyboard.press(pin_input_13);
        delay(50);
       Keyboard.release(pin_input_13);
    }
    lastswitchState_13 = switchState_13;
}

ok try this, haven't tested it:

bool g_toggle = false;// put this line with your globals

if (switchState_13 != lastswitchState_13)
{
	g_toggle != g_toggle;
	char input = '#';
	if( g_toggle )
		input = '/';
	Keyboard.press(input);
	delay(50);
	Keyboard.release(input);
}

It doesn't work, it outputs "#" both times.

Yea my bad, that'll teach me to read it before I post.

change this line:

g_toggle != g_toggle;

to this:

g_toggle = !g_toggle;

Haha don't worry, it works now, thank you so much.