XLib Input Fixes

Added XLib keyboard input fixes by use canthelp on IRC, also ssss on forums. Tested and works.