pqrs-org / Karabiner-Elements

Karabiner-Elements is a powerful utility for keyboard customization on macOS Sierra (10.12) or later.
https://pqrs.org/osx/karabiner/
The Unlicense
18.28k stars 830 forks source link

Bug: Caps Lock delay not working properly #1358

Closed devvythelopper closed 5 years ago

devvythelopper commented 6 years ago

I just updated to karabiner elements v12.

Now my caps lock delay setting (I think this was the default) is not working anymore:

"virtual_hid_keyboard": { "caps_lock_delay_milliseconds": 0, "country_code": 1, "keyboard_type": "ansi" }

tekezo commented 6 years ago

The caps_lock_delay_milliseconds is dropped since v12.0.0.

Please consider using hold_down_milliseconds with the latest beta version. https://github.com/tekezo/Karabiner-Elements/issues/1349#issuecomment-381379081

devvythelopper commented 6 years ago

Thanks for providing support so blazingly fast. But this is not going to work for me.

My configuration is as follows: I created my own .keylayout (in a .bundle) and used capslock as an additional modifier. Using karabiner I turned my capslock into a non locking modifier. I basically need it to be down the moment I press it or else I just cannot use it as a modifier anymore.

And apple isn't very generous with modifiers either. They have control (supposed to mean left) and rightControl in their configuration file, but basically only anyControl works (analogously with anyShift, anyAlt, ...).

Since I cannot implement my keyboard layout completely using karabiner (because it cannot output characters), I am stuck at v11.6. (Not that I have time to reimplement it...).

tekezo commented 6 years ago

There is a configuration that changes caps lock to command+control+option+shift. You can change caps lock to other keys without delay. I guess you can use this setting for your purpose.

180419-0001

Or you can change caps lock to virtual modifier in Karabiner-Elements. https://pqrs.org/osx/karabiner/json.html#virtual-modifier

devvythelopper commented 6 years ago

Thank you very much, I could use command+control+option+shift as another modifier you are right about that.

I would however like to not do that, because in some applications this has interesting sideeffects (for example in Virtualbox I use option+command as host key combination and hitting command+control+option+shift would activate it).

The whole point is, that I am using caps_lock as a modifier, not to trigger keyboard shortcuts but to issue characters as text. So using any one of command/control/option will interfere with what I desire, because applications interpret as keyboard shortcuts...

A virtual modifier also does not help, because I need a real modifier, that the .keylayout can work with.

You have no idea how much headache it cost me to find a viable solution to that problem in the first place ;-)

One could however add the possibility to issue characters using karabiner. Then I could port my whole keyboard layout to a karabiner.json file. That would be the best possible solution, but I guess it propably has unwanted sideeffects too, since then my keyboard shortcuts would not work as expected... But using karabiner I could propably work around that too.

It would however be much easier to have some tool that just turns off caps lock delay. Be that karabiner or not. There is an interesting solution for this on stackexchange. Using this trick you might be able to reenable the caps_lock_delay setting with your new virtual karabiner keyboard: https://apple.stackexchange.com/a/199958/230621

ptram commented 6 years ago

I'm not sure I understand how to modify the ~/.config/karabiner/karabiner.json file to remove CapsLock delay. May I ask some more information on how to add the code to remove it?

Thank you! Paolo

slowkow commented 6 years ago

@tekezo I tried to use hold_down_milliseconds like you suggested, but I'm still facing the same problem.

Here is my config:

{
  "title": "caps_lock → escape (without delay)",
  "rules": [
    {
      "manipulators": [
        {
          "description": "caps_lock → escape",
          "from": {
            "key_code": "caps_lock",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": [
              {
                  "key_code": "caps_lock",
                  "hold_down_milliseconds": 0
              }
          ],
          "to_if_alone": [
              {
                  "key_code": "caps_lock",
                  "hold_down_milliseconds": 0
              }
          ],
          "type": "basic"
        }
      ]
    }
  ]
}

I still encounter delay when I press caps_lock.

Here is an example. I open my terminal (where I use vi mode on the command line). I press i a few times, then press caps_lock (maps to escape) and h.

2018-04-22_08-47-02

The EventViewer correctly sees that I pressed the keys in this order:

  1. escape
  2. h

However, my terminal incorrectly receives the keys in this order:

  1. h
  2. escape

It is confusing to see that programs disagree about the order in which keys were pressed.

If I type very slowly, then both programs agree about the order. I have to type like this:

  1. escape
  2. Wait for a few milliseconds
  3. h

Is there anything I can do to completely disable the delay on caps_lock? I already tried the advice from Apple forums: "map caps lock to nothing and then map caps lock to caps lock". That didn't work for me.

I'm using macOS High Sierra 10.13.3 and Karabiner-Elements 12.0.6

devvythelopper commented 6 years ago

@slowkow & @ptram the suggestion to use hold_down_milliseconds is only a solution if you were implementing a key sequence. In other words if you would use karabiner to first trigger caps_lock, then to wait a few milliseconds, then to trigger h (all that using karabiner). hold_down_milliseconds is meant to wait for caps lock to enable it (because it is delayed by the OS) and to simulate the next button press after waiting.

If you however use caps_lock as a modifier (like me) and then press another button manually (or something similar), then you are out of luck with karabiner v12.0.+

caps_lock_delay has been dropped as of v12.0.0 as @takezo wrote. Thus I am continueing to use v11.6. It's not a real solution but we will have to wait for @takezo to reimplement caps_lock_delay with the new virtual keyboard. The link I gave him, suggests how this might be possible, so there is hope.

(If you knew C you could try to disable the delay on karabiners virtual keyboard yourself and help takezo)

matsaman commented 6 years ago

I'll also be sticking with older versions. Not to reduce what's clearly a great app, but roughly 2000% of the time I'm using Karabiner-Elements it's solely to disable the caps lock delay.

bingocaller commented 6 years ago

It is possible to eliminate the Caps Lock delay on macOS High Sierra (10.13).
It involves enabling Slow Keys; however, that comes with a pretty hefty trade-off: your key repeat rate will become so sluggish that it will be all but unusable. This Stack Overflow answer from the same thread that @devvithelopper linked to, has the details. I'll post the full answer here for posterity/to save you a trip:

Here is the fix for macOS Sierra.

Go to System Preferences > Accessibility

When the accessibility window is open — on the left part of the window – click Keyboard

Then there will be the 2 options — for sticky keys, and for slow keys — click the box next to slow keys to enable it — then click the Options… button – a new window will come up with a slider to change the acceptance delay — by default this is in the middle. Slide the button all the way to the left, so that it is the shortest time possible.

Now it should be fixed. Have not experimented to see if the fix stays upon restart, but I’m hopeful that it will.

Answer OP: michelle

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

devvythelopper commented 5 years ago

For everyone for whom this is an issue please consider subscribing to it so that @tekezo can see, that people are affected by this. (@tekezo is it really that much work to use the old way of simulating key events just for caps lock?)

If anybody finds some way of disabling the caps-lock delay without those heavy tradeoffs I'd highly appreciate it. I will continue using karabiner though for all the other great features, no bad feelings here.

ptram commented 5 years ago

I agree this is a very important issue, and hope it can be solved.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

mikerogne commented 5 years ago

Came here via Google... wishing I didn't have to revert back to an older version for this :(

tekezo commented 5 years ago

Try this. https://pqrs.org/osx/karabiner/help.html#disable-caps-lock-delay

jeremytwork commented 5 years ago

Thanks @tekezo for that link. Caps lock is now working as originally intended on an iMate ADB-USB keyboard in 10.12.6!

ghost commented 5 years ago

FYI https://pqrs.org/osx/karabiner/help.html#disable-caps-lock-delay works but still leaves a noticeable lag when using Caps Lock. Karabiner-Elements 11.6.0 truly removes the delay.

mmatrosov commented 1 year ago

The update link is: https://karabiner-elements.pqrs.org/docs/help/how-to/disable-caps-lock-delay/

However, it does not seem like it solves the issue. At least not entirely. I use CapsLock to change the input method. And the input is changed without a delay if CapsLock is pressed after other keys. E.g. if I hit fast LKJ⇧, the input is changed. But if I hit fast ⇧LKJ, then the input does not change.