pqrs-org / Karabiner-archived

Karabiner (KeyRemap4MacBook) is a powerful utility for keyboard customization.
https://pqrs.org/osx/karabiner/
The Unlicense
3.82k stars 311 forks source link

How to turn caps lock + W/S/A/D into Arrow Keys #870

Open weiweihuanghuang opened 6 years ago

weiweihuanghuang commented 6 years ago

Hi, thanks again for maintaining this app!

I tried the following, but what happens is that it works but I can't hold down caps lock and w and make it persist as up arrow, it works once then goes back to w.

{
                      "description": "Change Caps Lock + W/S/A/D to Arrow Keys",
                      "manipulators": [
                        {
                          "type": "basic",
                          "from": {
                            "key_code": "w",
                            "modifiers": {
                              "mandatory": [
                                "caps_lock"
                              ],
                              "optional": [
                                "any"
                              ]
                            }
                          },
                          "to": [
                            {
                              "key_code": "up_arrow"
                            }
                          ]
                        },
                        {
                          "type": "basic",
                          "from": {
                            "key_code": "a",
                            "modifiers": {
                              "mandatory": [
                                "caps_lock"
                              ],
                              "optional": [
                                "any"
                              ]
                            }
                          },
                          "to": [
                            {
                              "key_code": "left_arrow"
                            }
                          ]
                        },
                        {
                          "type": "basic",
                          "from": {
                            "key_code": "s",
                            "modifiers": {
                              "mandatory": [
                                "caps_lock"
                              ],
                              "optional": [
                                "any"
                              ]
                            }
                          },
                          "to": [
                            {
                              "key_code": "down_arrow"
                            }
                          ]
                        },
                        {
                          "type": "basic",
                          "from": {
                            "key_code": "d",
                            "modifiers": {
                              "mandatory": [
                                "caps_lock"
                              ],
                              "optional": [
                                "any"
                              ]
                            }
                          },
                          "to": [
                            {
                              "key_code": "right_arrow"
                            }
                          ]
                        }
                      ]
                    },

Here is the EventViewer

eventType:key_down        code:0x39       name:caps_lock       misc:
eventType:key_up          code:0x39       name:caps_lock       misc:
eventType:key_down        code:0x50       name:left_arrow      misc:
eventType:key_down        code:0x39       name:caps_lock       misc:
eventType:key_up          code:0x50       name:left_arrow      misc:
eventType:key_down        code:0x4        name:a               misc:
eventType:key_up          code:0x4        name:a               misc:
eventType:key_down        code:0x4        name:a               misc:
eventType:key_up          code:0x4        name:a               misc:
eventType:key_up          code:0x39       name:caps_lock       misc:
weiweihuanghuang commented 6 years ago

Any possibility here?

jandubois commented 5 years ago

@weiweihuanghuang I've run into the same problem: when used as a mandatory modifier, caps_lock is not being removed from the to event definition, creating problem when keeping it pressed down for multiple command sequences.

I've been able to work around this problem by using a "virtual modifier" as described in https://pqrs.org/osx/karabiner/json.html#virtual-modifier.

Just for reference, this is my commit that fixed my definitions for +0 to +9

https://github.com/jandubois/karabiner/commit/7b57fabd016e1d05548c67d66ca82f7731de7243