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).

Artur Meinild
  • 26,018
Karsten Decker
  • 453
  • 1
  • 4
  • 4
  • Welcome to askubuntu! Have you tried the software center? You can install it from there and then follow the instructions here:http://askubuntu.com/questions/453793/remapping-caps-lock-in-14-04-trusty-tahr – Elder Geek Jan 15 '15 at 21:35

10 Answers10

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.

Bentley Carr
  • 1,317
  • 1
  • 13
  • 23
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

Bentley Carr
  • 1,317
  • 1
  • 13
  • 23
  • 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). – Karsten Decker Jan 16 '15 at 14:32
  • I think it was additional shift key. Anyway, glad it helped! – Bentley Carr Jan 16 '15 at 14:36
  • 1
    works in 17.10! –  Nov 12 '17 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 09 '21 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.

brunch875
  • 241
  • 2
  • 5
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
WitchCraft
  • 1,834
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.

  • 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. – Fred Hamilton May 05 '16 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. – nicorellius Jun 21 '18 at 17:19
  • @nicorellius: This was the case on 15.04 when writing of the answer was done. –  Jun 21 '18 at 18:56
  • My bad, I was responding thinking it was for 16.04. Thank you. – nicorellius Jun 22 '18 at 00:17
  • @nicorellius:Ok, that's fine. –  Jun 22 '18 at 04:49
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.

Alex
  • 101
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"
dufte
  • 13,272
  • 5
  • 39
  • 43
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
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']"