Corrections to keyboard grab/ungrab. Fixes #245

fixes #245