arduino-libraries / Keyboard

GNU Lesser General Public License v3.0
225 stars 158 forks source link

Modifier keys are set incorrectly on ::press() when _keyReport.keys is full. #5

Open ZDBioHazard opened 8 years ago

ZDBioHazard commented 8 years ago

If Keyboard.press() is called with a key that implies a modifier, when _keyReport.keys[] is full, the modifier bit will still be set on _keyReport.modifiers, but sendReport() never gets called for that key, leaving the modifier pressed but not reported until the next possible ::press(), which may or may not be after a ::release() that clears the modifier.

Also, if you ::press() two capital letters and ::release() one, the modifier will be cleared even though the second key is still pressed. Maybe there should be some documentation discouraging the use of ::press() with shifted keys? You shouldn't need them outside of string printing, which you should be using ::write() for anyway.

I was hoping I would have a chance to fix it so it doesn't set the modifier unless the key can be pressed, but I may not have time for a little while.