Move keypress print func to before main

Means we need no separate declaration, and it's a lot easier to infer
that the function is pure.
Document keyState function

Yeah, that did look a bit arcane.
Unextract printKeyPress

This is clearer to read, as the amount of state being passed into the
utility function caused more distracting boilerplate than having a
separate function was worth.