2

I want my shift lock button to act like escape in linux(ubuntu) for in vim. I did the following in my home directory:

  1. xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'
  2. xmodmap -pke > .Xmodmap
  3. Create .xinitrc in home folder en paste: xmodmap .Xmodmap in that file.

resources:

https://askubuntu.com/questions/24916/how-do-i-remap-certain-keys How to map CAPS LOCK key in VIM?

The problem is that now my shift lock key is acting like shift lock AND escape at the same time, how can I change it to act solely like escape?

Community
  • 1
  • 1
Bentley4
  • 10,678
  • 25
  • 83
  • 134
  • I can't test this at the moment but I think you should just be able to run `setxkbmap -o caps:escape` to make Caps Lock an additional Escape. – Randy Morris May 28 '12 at 16:57
  • 1
    Using Xkb as @RandyMorris described would make the use of xmodmap superfluous (or maybe even detrimental). – echristopherson May 28 '12 at 18:29
  • Which Ubuntu/gnome version are you using? There is a better solution without using xmodmap. – Magnun Leno May 28 '12 at 21:28
  • @Magnus Leno: Ubuntu 11.10, Oneiric. – Bentley4 May 29 '12 at 08:29
  • @echristopherson: why would it be detrimental? What would be your solution? – Bentley4 May 29 '12 at 08:31
  • 1
    @Bentley4 I'm not sure it would be detrimental; it's just that xmodmap and setxkbmap use two different interfaces to the X server to modify key bindings, so there may or may not be a conflict. setxkbmap is the newer of the two, and the one most likely to keep working in the future. – echristopherson May 29 '12 at 15:00
  • 1
    Since you use Ubuntu 11.10, there is a better solution (in my opinion). Just forget about setxkbmap and xmodmap and use default gnome settings :D, just look at the answer below. – Magnun Leno May 29 '12 at 16:27

2 Answers2

5

For Ubuntu 11.10+ (with Gnome 3 libraries) there is an "almost hidden" keyboard options which allows you to change many keys behaviors. To make Caps Lock act like an additional ESC follow these steps:

1. System -> Preferences -> Keyboard
2. Select Layouts tab, then Layout Options
3. Click on 'CapsLock key behavior'
4. Click on 'Swap ESC and CapsLock'

Here is a print screen: Gnome 3 - Make Caps Lock an additional ESC

As shown above there are many other possibilities, like "Swap ESC and Caps Lock". Also, if you miss your Caps Lock functionality, there is an option to "map Caps Lock behavior" for other keys/keys combinations. Just read all options, test a couple and pick your favorites.

Magnun Leno
  • 2,728
  • 20
  • 29
0

You can also use the command under the X window.

/usr/bin/setxkbmap -option "ctrl:swapcaps"
Chu-Siang Lai
  • 2,658
  • 1
  • 24
  • 21