10

Yesterday I installed Ubuntu on my Laptop, but there's a problem with Caps Lock. When pressing the Caps Lock button, there is a small delay before it actually toggles. This problem does not show up in Windows 7.

I'm learning Java and Android and the Caps Lock delay problem is really bad. For example:

SYstem.out.println("HEllo UBuntu!!);

Does anyone knows how to fix this? I've seen a lot of people saying "use Shift", but is there any other way to fix this delay?

Lekensteyn
  • 174,277
kushtrimh
  • 277
  • 2
  • 4
  • 10

2 Answers2

6

You should learn to use Shift instead, which is the common way to enter a capital letter.


If you want to hit Caps Lock anyway to produce a capital letter, do note that there are reports that the delay is a known issue (Launchpad Bug #1376903). The Arch Linux wiki describes a method to remove this delay which seems to work.

For your convenience, this script performs the manual steps documented at that wiki page:

#!/bin/sh
xkbcomp -xkb "$DISPLAY" - | sed 's#key <CAPS>.*#key <CAPS> {\
    repeat=no,\
    type[group1]="ALPHABETIC",\
    symbols[group1]=[ Caps_Lock, Caps_Lock],\
    actions[group1]=[ LockMods(modifiers=Lock),\
    Private(type=3,data[0]=1,data[1]=3,data[2]=3)]\
};\
#' | xkbcomp -w 0 - "$DISPLAY"

This needs to be started as part of your desktop session (do not use Upstart for example). See this post for a method. Do not forget to enable the execute bit of the script.

Lekensteyn
  • 174,277
  • 1
    Thank you for your time, I think I'll start using Shift. :) – kushtrimh Jan 17 '15 at 14:03
  • Oh, I thought it was much harder to change behavior. I guess the hassle was not worth it to stick to Caps Lock :P – Lekensteyn Jan 17 '15 at 14:44
  • Who, hold down shift to type all the letters that capitalized or lowercase? – Ahmet Erkan ÇELİK Oct 02 '15 at 18:02
  • This doesn't fix my problem. I try to type "I'm" and I get "I?m". What do I do? – Foxcat385 Apr 19 '19 at 17:15
  • How can it still be an issue where a simple script solves the problem? – Agustin Barrachina Oct 04 '19 at 09:33
  • Does someone from Ubuntu want to include this in the next release??? – user997112 Aug 10 '22 at 15:06
  • Has there been a change to sed that could break this? I've tried copying this script (control+c; control+v) verbatim, and get the error (in bash) Errors encountered in stdin; not compiled.? sed (GNU sed) 4.8; Also, I attempted to manually make the corresponding changes, but didn't see any immediate improvement in the delay. (Do I need to re-load the session or restart applications for it to take effect?) – MRule Oct 12 '22 at 12:01
1

This Github project fixes this issue, especially for Java on Ubuntu:

Check this out: https://github.com/Jagden/CapsDelayJavaAwtProblem