Teensy - slow response from computer

Hello and hi. I am making a school project with Teensy 2.0, and obviously I have got a little problem. So, I will start with my code:

void setup(){
  Serial.begin(9600);
  pinMode(10, INPUT);
}
void loop(){
if(digitalRead(10) != HIGH){
    Keyboard.set_modifier(MODIFIERKEY_GUI);
    Keyboard.send_now();
    Keyboard.set_key1(KEY_L);
    Keyboard.send_now();
    Keyboard.set_modifier(0);
    Keyboard.set_key1(0);
    Keyboard.send_now();
 };
}

In options: "Board" is switched to "Teensy 2.0", USB type: "Keyboard + mouse + joystick", +5V is provided to pin 10. OS is WinXP SP2, but on other WinNT based OSes it's the same. It is supposed to send to computer key combination (WIN+L - lock Windows) immediately after the button is pulled up (It should be pushed down at most times). And here is a problem - when I pull the button up, at first sight nothing is happening and finally, after 7-30 seconds (which isn't immediately for sure), it is locking. When I am entering password and pressing enter (when button is still pulled up), it locks immediately, but when I push it down again, log in and again, pull up, situation with long delay repeats. So, at this point, I don't really know why there are so long delays, if it is depending on the board or a computer. And how to get rid of them. I hope I described my problem clearly. Cheers, Maziu.

Let's determine, first, if you have a hardware issue or a software issue. Hardware first. How is your switch wired? Why are you not using the internal pullup resistor which allows you to not need an external resistor?

Now, it is just a wire connected to +5V and pin 10, but I think it will be the same problem if I got a real button.
If I understood well, you are asking why I am using “INPUT” instead of “INPUT_PULLUP”? When I checked it before, it didn’t work quite well (or I used it in wrong way).

If I understood well, you are asking why I am using "INPUT" instead of "INPUT_PULLUP"? When I checked it before, it didn't work quite well (or I used it in wrong way).

That was the question. The reason it didn't work is that the pullup pulls the pin UP to 5V. Then, you ground the pin to "press the switch".

OK, I will check it later and tell how it went. Thanks for now.

I don't know if any debouching might help? There is a good denounce library in playground. This helped me out with a problem I had that sounds similar to yours.

The Teensyduino installer puts some examples in the menu for you. Look in File > Examples > Teensy > USB_Keyboard > Buttons for an example that connects 10 pushbuttons. It "types" messages when each button is pressed and released.

You can run the example without any hardware, and just use a wire or paperclip to touch between the GND pin and any of the pins the example uses.