add key press event mask and grab keyboard until it succeeded
on error write to error file