it seems that the Caps Lock key does not have the same behaviour as other keys.
If you press it and next release it, you get only the KEYDOWN event.
It is necessary to press/release it again for having the KEYUP event.
So, you need to press it 2 times instead of one.
In fact, the event depends on the Caps Lock LED.
I would like to know whether ther is a way to change this.
Under X11, the Caps Lock acts as any other key.