cleanup:
Refactor keyboard generation function using a more functional style