Corrections to keyboard grab/ungrab. Fixes #245