Ubuntu – Ubuntu 14.04 + VMware 6: Left Ctrl and Right Shift not functioning

keyboardunityvmware

Before I launch a virtual machine in VMware, all the modifier keys function properly. Even when I launch VMware, but before I start the virtual machine everything works great.

However once I start a virtual machine my left Ctrl and right Shift keys stop functioning. They simply have no affect.

Here are a few observations that might lead to something:

  • My left Shift still keeps working.
  • I mapped my Caps Lock to Ctrl and it works properly.
  • Executing sudo setxkbmap temporarily sets everything in order. Once VMware gains focus and I type something, problem comes back.
  • Problem persists even after I quit VMware.

This is the first time I'm using Unity (I have been using Gnome for a long time) and I'm suspecting the problem is related to that. Any ideas why this might be happening?

Best Answer

TLDR:

In Gnome Tweak Tool, set "Ctrl key position" to "Caps Lock as Ctrl" and "Caps Lock key behavior" to "Caps Lock is disabled".

Full story:

The problem appears to be how Ubuntu is remapping the CapsLock key. When Gnome Tweak Tool's "Caps Lock key behavior" property is set to "Make Caps an additional Ctrl", xmodmap reports:

xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Caps_Lock (0x42),  Control_R (0x69)
mod1        Alt_L (0x40),  Alt_R (0x6c),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3      
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

The problem appears to be that both lock and control list "Caps_Lock (0x42)". Everything works well until you set focus into a VMWare VM (I tested using VMWare Player). After focusing VMWare's window, xmodmap will report an empty mapping:

xmodmap:  up to 0 keys per modifier, (keycodes in parentheses):

shift     
lock      
control   
mod1      
mod2      
mod3      
mod4      
mod5      

Running setxkbmap resets the keyboard mapping and temporarily resolves the issue. Playing with xmodmap, I found that removing Caps_Lock (0x42) from lock stopped VMWare from flushing the keyboard mappings. But, Ubuntu 14.04 ignores .Xmodmap files, so there was no simple method to use xmodmap.

We can fix the root-cause of this situation by changing two settings in Gnome Tweak Tool, as described at the top of this post. Doing so will properly configure the keyboard mappings so that Caps_Lock (0x42) does not show up in two locations:

xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock      
control     Control_L (0x25),  Control_L (0x42),  Control_R (0x69)
mod1        Alt_L (0x40),  Alt_R (0x6c),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3      
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)