Automatically detect Xkb at run-time.

Uses XGetKeyboardMapping as a fallback.  Fixes #282.
Cleanup of XKB detection code.
Cleaned up shared key repeat detection.