VMWare messing up ctrl/alt keys on Linux? Reset key mappings with this command

With Openbox on Ubuntu 10.04 I kept having an issue where VMWare would randomly destroy my key mappings and stop my ctrl and alt keys from working correctly, the only solution seemed to be restarting openbox or X, and in the middle of work that’s not an option. So here’s a command to reset your keyboard with the least amount of disruption:

setxkbmap us -print | xkbcomp - $DISPLAY

A much better solution than restarting X. Took me ages to find this, so hopefully this helps someone. I’d still like to find a fix instead of a workaround.

2010.06.10