Conditionalize use of gdk_keyboard_grab/ungrab().