Post-mortem update: After wrestling with xmodmap for the better part of the morning, I found this answer perfectly solves the issue. The reason, I believe, is that xmodmap is not as powerful as xkb, and xkb is closer to the keyboard hardware. After following these steps my KUL ES-87 with the Alt and Super keys switched and in "OS X Mode" is behaving like an Apple keyboard.

I just remapped some modifier keys with xmodmap using this script:

remove mod4 = Super_L
remove control = Control_L
add control = Super_L
add mod4 = Control_L

The Super key does work as Control (I can copy and paste using the Super key as it is mapped to the Control key). However, I cannot use the Control key (mapped to Super) for tasks Super is used for in Ubuntu like viewing the notification bar with Super+V or switching workspaces with Super+PgDn.

Oddly, when I go into Keyboard Shortcuts to remap these functions, it sees the keystrokes as I would expect. If I press Crtl+V on my keyboard, it records that I sent Super+V, yet trying to use this key combination in any other context outside of recording the shortcut in Keyboard Shortcuts still doesn't work. So, the Keyboard settings are correctly interpreting the modified key mapping, but they are still not working for their function. If I reset xmodmap Super and Control work as expected and all shortcuts work like they did out of the box.

What is the cause of this issue and how can I make my keyboard behave as expected?

Update: I reset xkb to default (which also reset xmodmap) and then updated xmodmap mappings using keycode. This had no effect except to disable the super key (this key no longer works to open the notification list, yet is still registering as the super key in Keyboard Shortcuts, and somehow the left Ctrl key retains Control_L functionality (I can copy and paste from this key, and Keyboard Shortcuts still recognizes it as Control when assigning a new shortcut) What the heck is going on??

m@buntoo:~$ setxkbmap -layout us
m@buntoo:~$ xmodmap -pke | grep 'Super\|Control'
keycode  37 = Control_L NoSymbol Control_L
keycode 105 = Control_R NoSymbol Control_R
keycode 133 = Super_L NoSymbol Super_L
keycode 134 = Super_R NoSymbol Super_R
keycode 206 = NoSymbol Super_L NoSymbol Super_L
m@buntoo:~$ xmodmap -e "keycode 37 = Super_L"
m@buntoo:~$ xmodmap -e "keycode 133 = Control_L"
m@buntoo:~$ xmodmap -pke | grep 'Super\|Control'
keycode  37 = Super_L NoSymbol Super_L
keycode 105 = Control_R NoSymbol Control_R
keycode 133 = Control_L NoSymbol Control_L
keycode 134 = Super_R NoSymbol Super_R
keycode 206 = NoSymbol Super_L NoSymbol Super_L
m@buntoo:~$ xmodmap -e "keycode 206 = Control_L"
m@buntoo:~$ xmodmap -pke | grep 'Super\|Control'
keycode  37 = Super_L NoSymbol Super_L
keycode 105 = Control_R NoSymbol Control_R
keycode 133 = Control_L NoSymbol Control_L
keycode 134 = Super_R NoSymbol Super_R
keycode 206 = Control_L NoSymbol Control_L
m@buntoo:~$ 

In addition to removing and adding mod4 and Super_L, swap keycodes.
Get keycodes with xmodmap -pke and swap the values. For me, keycode 37 = Control_L NoSymbol Control_L), so I do:

xmodmap -e "keycode 37 = Super_L"

and the other two if needed. I cannot test exactly, I have a keyboard without Super_L.

  • Thanks for your answer, but there are still issues. I updated my question with the results of this suggestion. Do you know of a way to test which signal the operating system receives when a key is pressed? (Other than assigning shortcuts in Ubuntu's Keyboard Shortcuts which is the method I'm currently using.) – Michael Fulton May 15 at 18:08
  • have you used xev? – Andra May 15 at 18:10
  • 1
    did you do all the commands: remove control, assign keycode, add control? It's not enough just to change keycodes. – Andra May 15 at 18:13
  • Thanks, I used just used xev. It reports Super_L is indeed 133, but does something different for Ctrl which, inconveniently in this case, switches windows. I'll update my script to remove, assign, then add and report back. – Michael Fulton May 15 at 18:15

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.