This change is needed for all new versions of the Arduino IDE and applies to code listings: 5-2, 5-3, and 5-8. The code has been updated on GitHub with additional revised code listings.
After the code line: keyboardByte = Serial.read(); we added the following: (Note: keyboardByte is the variable.)
//The code != 10 ignores the value 10 (the value sent when pressing the enter key). Also, add a closing brace at the end of the main loop.