From the early history of Arduino ...
May give you a few ideas about parsing the keyboard and configuring the system to be expandable.