adafruit/USB-NeXT-Keyboard — pull request #1 by DanaDanger (2012-12-20 19:38:57+00:00)
Title: sticky modifier keys

Hi Limor! Thanks so much for releasing this code. I've been dying to use my NeXT keyboard again and this is just the ticket.

Everything is working swimmingly except for one problem I've noticed with the modifier keys. When a modifier key and a non-modifier key are released at the same time, the NeXT keyboard sends a single message containing the new modifier mask and the non-modifier key's keycode. Because the keycode in this message is non-zero, the line "if (keycode == 0)" skips the modifier key updates, so the modifier release never gets sent to the host computer. Hilarity ensues, especially if the stuck key is Command!

Fortunately the solution is pretty simple. This patch updates the modifier keys on every message, regardless of whether the message contains a keycode. The keycode == 0 conditional moves down to the return statement, so we still skip the non-modifier key press if we get a message with no keycode.

Thanks again for this awesome project!
Dana