Refactor keyboard example