43

I really don't need Caps Lock (who does?) and would rather have it as a Shift key as I sometimes hit it by mistake especially on the small netbook keyboard.

Since I don't read while I type this might mean I have to retype half a page. I only find solutions for Ubuntu 12.04 but they don't work for 14.04 (Somehow the "typing" dialog looks totally different, not as user friendly).

I've tried anyway and clicked on + to make a custom shortcut. It asked me for a name (I put Name: Caps Lock) and for a command (command: disable, and I also tried command: Shift), but that did nothing. It shows on right side under custom shortcut, but I still have Caps Lock.

I am new at Linux so please, if you have an answer don't just say: Use mxpt.de or so, but please tell me how to get to the dialog box or to a command prompt and what I need to do. (Somebody had a solution with Gnome Tweak or so, but I cannot find that program in Ubuntu 14.04).

1

10 Answers 10

49

Opening a terminal and typing in:

xmodmap -e "keycode 66 = Shift_L NoSymbol Shift_L" 

followed by enter/return should remap the Caps Lock button the Left Shift.

However, this will need to be executed on each boot. You can do the following to automatically run this every time the system boots.

  1. Search "Startup Applications" in the dash and open it.

  2. Click add. For the name put "Caps Lock to Shift" and under "command" put xmodmap -e "keycode 66 = Shift_L NoSymbol Shift_L".

  3. Press save and restart. Enjoy!


If you would rather disable Caps Lock, you can execute the following (in terminal):

setxkbmap -option caps:none

Once again, this will reset once you restart, so add a startup entry (like above) to execute this on boot.

4
  • 2
    With this I got where I wanted to be. Than you. Great help including explaining how to get there. Jan 16, 2015 at 14:46
  • No problem, @Karsten Decker! Jan 17, 2015 at 0:01
  • 2
    I used the second one as the question is TL;DR and comes up first when you google how to disable caps lock.
    – RexFuzzle
    Jun 5, 2016 at 6:06
  • This should be default lol!
    – PeterM
    Aug 12, 2019 at 12:16
32

You can remap Caps Lock is by using Gnome Tweak Tool.

You can install it via the Ubuntu Software Center if you wish or by the command line; it does not come installed on Ubuntu 14.04 by default.

  1. Open a terminal by holding CTRL, ALT and T at once or by search it in the dash.

  2. Type in sudo apt-get install gnome-tweak-tool. This tells apt-get to install gnome-tweak-tool. You need to have sudo as one needs to have root permissions to install software.

  3. Open Tweak Tool

  4. Select "Typing" from the left bar.

  5. Select "Caps Lock act as shift" where it says "Caps Lock key behaviour".

Screenshot depicting step 5 above.

Update for version 3.32.0-1

The option is now under:

Keyboard & Mouse > Additional Layout Options > Caps Lock behaviour

enter image description here
enter image description here

4
  • 1
    Thank you both of you. I used method of Yharooer, and was able to disable Caps Lock which is good enough. (I could not read the end of the options like in your screen shot, so it was a bit guessing what additional... it would be). Jan 16, 2015 at 14:32
  • I think it was additional shift key. Anyway, glad it helped! Jan 16, 2015 at 14:36
  • 1
    works in 17.10!
    – user372194
    Nov 12, 2017 at 16:41
  • In Fedora 34 this was the only solution that worked. Thanks! Curiously, after changing the Caps Lock key in the terminal, Tweaks knew that it had been remapped to Shift even though the key didn't act like it. When I changed it again in Tweaks it did fix it.
    – CyanCoding
    Jun 9, 2021 at 10:59
14

Newer method

More modern distros (ubuntu 20.04) now come installed with gsettings instead of dconf:

gsettings set org.gnome.desktop.input-sources xkb-options "['caps:none']"

Older way

As for ubuntu 17.04 you can set a dconf setting:

dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:none']"

No need to re-login.

3
  • 1
    Just to say the command below dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:none']" also works for ubuntu 16.04. Thanks to the poster.
    – ADW
    Apr 13, 2017 at 12:49
  • Also works on 18.04. Install Dconf-Editor with apt-get install dconf-editor -y.
    – AlainD
    Aug 26, 2019 at 12:35
  • Also works on 20.4
    – Martin
    Jun 5, 2020 at 11:25
9

To permantly disable CAPS-lock:

xkbset nullify lock

To re-enable it

xkbset nullify -lock.

To just toogle CAPS-lock:

sudo apt-get install xdotool
xdotool key Caps_Lock
1
  • 2
    Thank you! Just released me from a world of trouble
    – CIRCLE
    Feb 1, 2019 at 20:39
5

for Ubuntu 17.10

sudo apt install -y gnome-tweak-tool
  1. Open Gnome Tweaks
  2. Select Keyboard & Mouse from the left panel
  3. Click on Additional Layout Options from the right side
  4. Click the arrow next to Caps Lock key behavior. Set Caps Lock key to what you want.
2

There are many tools out there which can get the sort of thing you want. Probably the best one for you would be Gnome Tweak Tool. To install it, run this command in Terminal:

sudo apt-get install gnome-tweak-tool

Once it is installed:

  1. Open tweak-tool and click on the typing section in the left column.

  2. You should now see the line Caps Lock key behaviour on the left.

  3. Choose Disable from the drop-down list. And then it should disable the Caps Lock key.

5
  • Bums me out when when the first response/answer is the best answer but it doesn't get accepted and a copy of the first answer gets more votes. May 5, 2016 at 18:16
  • This answer might not technically be correct (or maybe have an alternate answer). On my system, Ubuntu 16.04, with Genome Tweak Tool, I had to choose the option Caps Lock is disabled rather than Disabled. The latter refers to disabling the Caps Lock key behavior in the tweak tool (I think), as mine was set to this option and the Caps Lock key still functioned as default. Jun 21, 2018 at 17:19
  • @nicorellius: This was the case on 15.04 when writing of the answer was done.
    – user364819
    Jun 21, 2018 at 18:56
  • My bad, I was responding thinking it was for 16.04. Thank you. Jun 22, 2018 at 0:17
  • @nicorellius:Ok, that's fine.
    – user364819
    Jun 22, 2018 at 4:49
0

This one is to disable the caps lock permanently without restart:

setxkbmap -layout us -option caps:ctrl_modifier gsettings set

org.gnome.desktop.input-sources xkb-options "['caps:ctrl_modifier']"

0

The other answers show 2 excellent ways to disable the key with a command (xmodmap -e "keycode 66 = Shift_L NoSymbol Shift_L" and setxkbmap -option caps:none) but no great way to run this at startup.

From https://askubuntu.com/a/934797/282454 with some minor edits:

  1. Place your script into a system-wide directory such as /usr/local/bin with an appropriate shebang

    [Removed script example]

  2. Make it executable e.g. sudo chmod +x /usr/local/bin/disable-caps.sh

  3. Create a custom config file in /etc/lightdm/lightdm.conf.d. Use a name such as 99-disable-caps.conf. (The 99 prefix means that it will be run after the standard setup scripts provided in /usr/share/lightdm/lightdm.conf.d.)

    Add the location of your script as a display-setup-script in the [Seat:*] section: [Seat:*] display-setup-script = /usr/local/bin/disable-caps.sh

    The display-setup-script should be run after the X server is started, but before any greeter is run - see LightDM: Adding system hooks.

[Seat:*] is relatively new (Ubuntu 15.10 and later); use [SeatDefaults] on older systems.

0

I tested the following on 16.04

1. Install DCONF

sudo apt-get install dconf-tools

2. Disabling classic caps behaviour

The following disabled the caps key

setxkbmap -option "caps:none"

3. Configure option to re-enable it (optional)

If you still want to be able to re-enabled caps but only by pressing both shift keys (left and right) at once try the following

setxkbmap -option "shift:both_capslock"
0

Here's my script that I use to enable/disable caps lock

$ cat ~/bin/caps
#!/bin/bash

let state=1
if [ $# -eq 0 ]; then
    xmodmap -pke | grep 'keycode\s\+66 = Caps_Lock' > /dev/null
    [ $? -eq 1 ] && let state=0
else
    [ "$1" == "on" -o "$1" == "1" ] && let state=0
fi

if [ $state -eq 1 ]; then
    echo "Caps lock off"
    xmodmap -e "keycode 66 = VoidSymbol NoSymbol VoidSymbol"
else
    echo "Caps lock on"
    xmodmap -e "keycode 66 = Caps_Lock NoSymbol Caps_Lock"
fi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .