yqrashawn / GokuRakuJoudo

config karabiner with ease
GNU General Public License v3.0
1.13k stars 122 forks source link

Force up_key events to occur after the modifier has been pressed? #231

Open aeberts opened 9 months ago

aeberts commented 9 months ago

TL;DR:

Question: Is there a way to make sure that modifiers do not send "up_key" events before the "any" portion of the modifier? Adding the option {:upwhen :all} does not seem to work. :-/

Full discussion:

Hi! I have a rule setup to turn capslock to hyper in non-unix like apps but it appears to send "up key" event before the optional "any" key is pressed which causes problems in some apps.

Here's the rule I have in karabiner.edn:

[:##caps_lock :!CTOleft_shift [:!unix-like]]

This rule gives me a hyper key so when I press the capslock key I get "Command + Control + Option + Left_Shift" plus whatever key I type after it. This works fine in most cases. However, when I snoop on the shortcut in Karabiner event viewer, I noticed that the modifier "key_up" events are being sent before the "any" key. Example for key press "Caps Lock" + d, I get the following sequence (notice that the "up key" events for control, shift, and option are being sent before the "down_key" event for "d"):

[
  {
    "type": "down",
    "name": {"key_code":"left_command"}, ... },
  {
    "type": "down",
    "name": {"key_code":"left_control"}, ... },
  {
    "type": "down",
    "name": {"key_code":"left_option"}, ...  },
  {
    "type": "down",
    "name": {"key_code":"left_shift"}, ... },
  {
    "type": "up",
    "name": {"key_code":"left_control"},  ... },
  {
    "type": "up",
    "name": {"key_code":"left_shift"}, ... },
  {
    "type": "up",
    "name": {"key_code":"left_option"}, ...  },
  {
    "type": "down",
    "name": {"key_code":"d"},  ...  },
  {
    "type": "up",
    "name": {"key_code":"d"}, ...  },
  {
    "type": "down",
    "name": {"key_code":"left_control"},  ... },
  {
    "type": "down",
    "name": {"key_code":"left_option"},  ... },
  {
    "type": "up",
    "name": {"key_code":"left_control"}, ...  },
  {
    "type": "up",
    "name": {"key_code":"left_option"}, ... },
  {
    "type": "up",
    "name": {"key_code":"left_command"}, ...  },
 ... ]

Is there a way to force the modifiers to release before the "any" key?

I tried doing [:##caps_lock :!CTOleft_shift [:!unix-like] {:upwhen :all}] but that doesn't seem to add anything to the corresponding rule in the generated karabiner.json file.

Thanks!