Ive gotten some questions in the past and i wanted to share this stump of code, had a small project some time ago where i handwired a keyboard, this is what came out of it.
Feel free to pull request, give suggestions etc.
https://github.com/ageaenes/teensykb