HID: Only works after upload

Thanks. Yes, there is a pull-down.

sterretje:
Your val variable is initialised with 0.

The first time you press the button, the if condition evaluates to true and val be be set 1 and after that the if condition will never evaluate to true so no space will be send.

True. But even when I reset the arduino or if I reconnect the Arduino to the power, it does not work! Only if I upload the sketch, it works after the upload.

Is there a problem with the serial connection? That the connection is only established when/after uploading, not if I plug in the Arduino without uploading the skecth? Seems so?