Keyboard bug fixes

This will close #151, #154 and #169