yqrashawn / GokuRakuJoudo

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

Strange behavior of sim layer #58

Closed lukakemperle closed 4 years ago

lukakemperle commented 4 years ago

I'm not sure if this is the problem with my Goku configuration, but maybe someone can give advice.

I utilize sim layer with s-key to navigate a cursor; adding a spacebar as a right_shift works great in all directions, only with the left_arrow/h doesn't work.

I quit Keyboard Maestro/Engine and Hammerspoon, disabled all shortcuts in Preferences: nothing helps.

I would really appreciate any suggestions since the shift is the only missing puzzle in this kind-of-vim navigation.

:simlayers {:s-mode {:key :s}}

{:des "s-key"
        :rules[:s-mode

        [:e :delete_forward]
        [:##d :delete_or_backspace]
        [:c :!Cdelete_or_backspace] ;; delete line

        ;; navigation
        [:##h :left_arrow]
        [:##k :up_arrow]
        [:##j :down_arrow]
        [:##l :right_arrow]

        [:spacebar :right_shift] ;; works with j/k/l, not with h/left_arrow

        [:##f :right_command]
        [:##a :right_option]

        [:##semicolon :return_or_enter]

        [:close_bracket :!CSslash] ; search/help
        [:open_bracket :!CTspacebar] ; emojis in Alfred

        [:r [:km "Cut Line"]]
        [:g [:km "Cut Word"]]]}

Thank you and stay safe!

yqrashawn commented 4 years ago

Are there any other rules that start with the h key? Like this issue.

lukakemperle commented 4 years ago

I isolated .edn file to only this

{:profiles 
    {:Default {
        :default true

        :sim     50
        :delay   80
        :alone   120
        :held    70}} 

:simlayers {
    :s-mode {:key :s}
}

:main [

    {:des "s-key"
        :rules[:s-mode

        [:##h :left_arrow]
        [:##l :right_arrow]
        [:spacebar :right_shift]
        ]}
        ]
}

Anyway, putting :spacebar before defining arrows, doesn't change the situation.

Here is my generated .json file:

{
  "global" : {
    "check_for_updates_on_startup" : true,
    "show_in_menu_bar" : true,
    "show_profile_name_in_menu_bar" : false
  },
  "profiles" : [ {
    "complex_modifications" : {
      "parameters" : {
        "basic.simultaneous_threshold_milliseconds" : 50,
        "basic.to_delayed_action_delay_milliseconds" : 80,
        "basic.to_if_alone_timeout_milliseconds" : 120,
        "basic.to_if_held_down_threshold_milliseconds" : 70
      },
      "rules" : [ {
        "description" : "s-key",
        "manipulators" : [ {
          "from" : {
            "key_code" : "h",
            "modifiers" : {
              "optional" : [ "any" ]
            }
          },
          "to" : [ {
            "key_code" : "left_arrow"
          } ],
          "conditions" : [ {
            "name" : "s-mode",
            "value" : 1,
            "type" : "variable_if"
          } ],
          "type" : "basic"
        }, {
          "type" : "basic",
          "parameters" : {
            "basic.simultaneous_threshold_milliseconds" : 250
          },
          "to" : [ {
            "set_variable" : {
              "name" : "s-mode",
              "value" : 1
            }
          }, {
            "key_code" : "left_arrow"
          } ],
          "from" : {
            "simultaneous" : [ {
              "key_code" : "s"
            }, {
              "key_code" : "h"
            } ],
            "simultaneous_options" : {
              "detect_key_down_uninterruptedly" : true,
              "key_down_order" : "strict",
              "key_up_order" : "strict_inverse",
              "key_up_when" : "any",
              "to_after_key_up" : [ {
                "set_variable" : {
                  "name" : "s-mode",
                  "value" : 0
                }
              } ]
            }
          }
        }, {
          "from" : {
            "key_code" : "l",
            "modifiers" : {
              "optional" : [ "any" ]
            }
          },
          "to" : [ {
            "key_code" : "right_arrow"
          } ],
          "conditions" : [ {
            "name" : "s-mode",
            "value" : 1,
            "type" : "variable_if"
          } ],
          "type" : "basic"
        }, {
          "type" : "basic",
          "parameters" : {
            "basic.simultaneous_threshold_milliseconds" : 250
          },
          "to" : [ {
            "set_variable" : {
              "name" : "s-mode",
              "value" : 1
            }
          }, {
            "key_code" : "right_arrow"
          } ],
          "from" : {
            "simultaneous" : [ {
              "key_code" : "s"
            }, {
              "key_code" : "l"
            } ],
            "simultaneous_options" : {
              "detect_key_down_uninterruptedly" : true,
              "key_down_order" : "strict",
              "key_up_order" : "strict_inverse",
              "key_up_when" : "any",
              "to_after_key_up" : [ {
                "set_variable" : {
                  "name" : "s-mode",
                  "value" : 0
                }
              } ]
            }
          }
        }, {
          "from" : {
            "key_code" : "spacebar"
          },
          "to" : [ {
            "key_code" : "right_shift"
          } ],
          "conditions" : [ {
            "name" : "s-mode",
            "value" : 1,
            "type" : "variable_if"
          } ],
          "type" : "basic"
        }, {
          "type" : "basic",
          "parameters" : {
            "basic.simultaneous_threshold_milliseconds" : 250
          },
          "to" : [ {
            "set_variable" : {
              "name" : "s-mode",
              "value" : 1
            }
          }, {
            "key_code" : "right_shift"
          } ],
          "from" : {
            "simultaneous" : [ {
              "key_code" : "s"
            }, {
              "key_code" : "spacebar"
            } ],
            "simultaneous_options" : {
              "detect_key_down_uninterruptedly" : true,
              "key_down_order" : "strict",
              "key_up_order" : "strict_inverse",
              "key_up_when" : "any",
              "to_after_key_up" : [ {
                "set_variable" : {
                  "name" : "s-mode",
                  "value" : 0
                }
              } ]
            }
          }
        } ]
      } ]
    },
    "devices" : [ ],
    "fn_function_keys" : [ {
      "from" : {
        "key_code" : "f1"
      },
      "to" : {
        "consumer_key_code" : "display_brightness_decrement"
      }
    }, {
      "from" : {
        "key_code" : "f2"
      },
      "to" : {
        "consumer_key_code" : "display_brightness_increment"
      }
    }, {
      "from" : {
        "key_code" : "f3"
      },
      "to" : {
        "key_code" : "mission_control"
      }
    }, {
      "from" : {
        "key_code" : "f4"
      },
      "to" : {
        "key_code" : "launchpad"
      }
    }, {
      "from" : {
        "key_code" : "f5"
      },
      "to" : {
        "key_code" : "illumination_decrement"
      }
    }, {
      "from" : {
        "key_code" : "f6"
      },
      "to" : {
        "key_code" : "illumination_increment"
      }
    }, {
      "from" : {
        "key_code" : "f7"
      },
      "to" : {
        "consumer_key_code" : "rewind"
      }
    }, {
      "from" : {
        "key_code" : "f8"
      },
      "to" : {
        "consumer_key_code" : "play_or_pause"
      }
    }, {
      "from" : {
        "key_code" : "f9"
      },
      "to" : {
        "consumer_key_code" : "fastforward"
      }
    }, {
      "from" : {
        "key_code" : "f10"
      },
      "to" : {
        "consumer_key_code" : "mute"
      }
    }, {
      "from" : {
        "key_code" : "f11"
      },
      "to" : {
        "consumer_key_code" : "volume_decrement"
      }
    }, {
      "from" : {
        "key_code" : "f12"
      },
      "to" : {
        "consumer_key_code" : "volume_increment"
      }
    } ],
    "name" : "Default",
    "parameters" : {
      "delay_milliseconds_before_open_device" : 1000
    },
    "selected" : true,
    "simple_modifications" : [ ],
    "virtual_hid_keyboard" : {
      "country_code" : 0,
      "mouse_key_xy_scale" : 100
    }
  } ]
}

Is there maybe smarter way to replicate kind of vim way (visual mode), using arrows, command and option keys? Thank you!

yqrashawn commented 4 years ago

With simlayer, you can just separate vim's normal and visual state like this

d+hjkl normal state v+hjkl visual state

lukakemperle commented 4 years ago

d+hjkl normal state v+hjkl visual state

You are right, it's much easier. I added few more for selecting text. Thank you.