help me please arduino leonard+fsx

hello, i m french, i m newbie, what i want seem to be easy, but after reading a lot, i dont find the answer... please help me i want to use arduino with flight simulator, with this software you can for example put the light on or off / start the radio / landing gear ...with a keyboard touch, i want to use arduino for the landing gear.

i have a button and when i turn the button high, the red led stop and the green is on, but the difficult thing for me is to send a message to fsx with the arduino leonardo, without the led it's ok, but the problem is to not repeat the keyboard.write when i don t use the button... thanks you for your help..

int buttonPin = 4;
int ledr = 3;
int ledv = 2;

void setup()
{
pinMode(buttonPin, INPUT);
pinMode(ledr,OUTPUT);
pinMode(ledv,OUTPUT);
Keyboard.begin();  
}

void loop() 
{
int valb = digitalRead(buttonPin);

if (valb == 1)
{
  Serial.println (valb);
  digitalWrite(ledv,0);
  digitalWrite(ledr,1);
  Keyboard.write('g');
}

if (valb == 0)
{    
  Serial.println (valb);
  digitalWrite(ledv,1);
  digitalWrite(ledr,0);
  Keyboard.write('g');
}
}
[code]

[/code]