I've gotten the code more or less in a shareable state. Still not perfect I'm sure, but good enough for now.
The layout for USB keyboarding is defined here:
If you don't need a USB keyboard and are rolling your own hardware project then you can focus on this layout:
There are three layers defined: base, shift, and Fn layers.
USB can be disabled by commenting out define USE_TEENSY_USB_KEYBOARD.
All the keyboardy goodness is handled by the keyboard_update(); function called from inside the standard arduino loop().
An alternative firmware option for a pure USB keyboard would be to run the excellent https://github.com/qmk/qmk_firmware.