Add tests for keyboard hack.
Improve keyboard hack.