X11 backend: add error checks in keyboard monitor