Prevent race on key->pid
Match keys by KeySym

Earlier only KeyCode was matched.  Useful for keys with several
levels.