Ubuntu – Problems with remapping Shift with Up keys

keyboardkeyboard-layoutremapping

I recently acquired a Lenovo 510-15 and using Right shift proves to be very bothersome, because of the terrible layout:

Poor Layout

So I tried to remap Right shift and Up keys, by running these commands:

xmodmap -e "keycode 62 = Up"        # => Up
xmodmap -e "keycode 111 = Shift_R"  # => Shift
xmodmap -e "add shift = Shift_R"    # Make the new Shift key actually shift
xset r 62                           # repeat Up key
xset -r 111                         # don't repeat new Shift key

They somewhat work, but with those following issues:

  1. Shift key works now as both Up and Shift simultaneously.

  2. Shift key won't repeat, meaning that, if I hold it down, it will only go one line up, unlike a normal up key, which continues to jump.

If anyone could help me sort these issues out or suggest an alternative way of fixing this problem it would be greatly appreciated.

Best Answer

I forgot to add this line:

xmodmap -e "remove shift = Up"

So it should look like this:

xmodmap -e "keycode 62 = Up"        # => Up
xmodmap -e "keycode 111 = Shift_R"  # => Shift
xmodmap -e "add shift = Shift_R"    # Make the new Shift key actually shift
xmodmap -e "remove shift = Up"      # Prevent the old Shift key from shifting
xset r 62                           # repeat Up key
xset -r 111                         # don't repeat new Shift key

I've got this solution from this Ask Ubuntu answer. I saved these lines as a .sh file and added it to my startup applications using KDE startup manager so I don't have to run these commands in the terminal after each restart. There is also an alternative, more universal way to make those changes permanent, described in the topic I've linked above.

Related Question