Simple Keyboard Button Question

Hello I am building a simple button on my Teensy and I set it up so that when pin 2 receives a signal "Low" it will type "A" however, this repeats and if the button is held down even a but it will do multiple A's Like this "AAAAAAAAAAAA" what commands can you recommend so it only types one A until the button is released and pressed again

Attached is what I have so far.

Thanks in Advance!

void setup() {
//Switch Input
pinMode(2, INPUT_PULLUP)
;}

void loop() {
//if pin recieves signal
if (digitalRead(2) == LOW)
{
//type "A"
Keyboard.print("A")

;}

}

A_Button.ino (171 Bytes)

In the IDE examples look at the state change detection example (File, Examples, Digital). It will show how to do what you want. Using state change detection, you look for the high to low (or low to high) transition, not the level.