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.78k stars 837 forks source link

Can't invert brackets () #2814

Closed locksoft closed 3 years ago

locksoft commented 3 years ago

I'm trying to swap some symbol keys, as my keyboard is in a different language.

As an example I want that, when I press shift-9 (that currently types a closed bracket ")"), it actually trigger the shift-8. But my rule is completely ignored. This is what I've added to .json file:

{ "description": "( su tastiera USA", "manipulators": [ { "from": { "key_code": "9", "modifiers": "shift" }, "to": [ { "key_code": "8", "modifiers": "shift" } ], "type": "basic" } ] },

What am I mistaking?

Thanks.

locksoft commented 3 years ago

Edit: I think I've solved this way (but I'm still not sure why the previous one doesn't work):

                    "manipulators": [
                        {
                            "from": {
                                "key_code": "9",
                                "modifiers": {
                                  "mandatory": [
                                    "shift"
                                  ]
                                }
                              },
                              "to": [
                                {
                                  "key_code": "8",
                                  "modifiers": [
                                    "shift"
                                  ]
                                }
                            ],
                            "type": "basic"
                        },
                        {
                            "from": {
                                "key_code": "0",
                                "modifiers": {
                                  "mandatory": [
                                    "shift"
                                  ]
                                }
                              },
                              "to": [
                                {
                                  "key_code": "9",
                                  "modifiers": [
                                    "shift"
                                  ]
                                }
                            ],
                            "type": "basic"
                        }
locksoft commented 3 years ago

Also, is it possible to use this method to add symbols that aren't in the keyboard? I don't know why but Big Sur doesn't add the "«" quoting symbol when I press option-1, while it adds the "»" when I press shift-option-1. I can't find anywhere a key_code for "«".

MuhammedZakir commented 3 years ago

First one didn't work because from.modifiers is incorrect. You can see the error in Krabiner-Elements Preferences > Log. In from, modifiers is an object with two keys - optional, and mandatory, whose values are a list of modifiers. Whereas, in to, modifiers is a list of modifiers. See the doc -- https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/from/modifiers/.


Also, is it possible to use this method to add symbols that aren't in the keyboard?

No. (but see below.)

I don't know why but Big Sur doesn't add the "«" quoting symbol when I press option-1, while it adds the "»" when I press shift-option-1.

If the keyboard layout you use has «, then you can insert it by pressing the corresponding keys. For instance, you will get » if you press shift+option+1, unless you have mapped shift+option+1 to something else, or are using it as keyboard shortcut, You can check which symbols your keybaord layout supports using on-screen keyboard. It is also helpful to get the correct key combination to insert a symbol.

I can't find anywhere a key_code for "«".

Karabiner deals with keycodes of a keyboard and how they get interpreted depends on macOS. Also, general keyboards doesn't have those symbols. That's why, you will have to also press option to access those special symbols.

locksoft commented 3 years ago

Thanks for your answer. I'm very new to Karabiner and I'm not good with coding, so I'm still learning. :)

The weird thing is that MacOS correctly shows the first three symbols on the keyboard (under numbers 1,2 and 3) but there's no way to type them, even if I use the virtual keyboard. I don't think that key combination is already taken by another command as nothing happens when I press it.

Schermata 2021-09-08 alle 16 12 45 Schermata 2021-09-08 alle 16 18 37
MuhammedZakir commented 3 years ago

I suspect you haven't focused on an input field [1] when you typed them (so you couldn't "see" the symbols you typed), or you didn't press correct key combination. I haven't used Italiano keyboard layout, but have used others and I'm able to type the symbols using them.

If, for some reason, you are still not able to type them, please post a screen record of you typing in EventViewer input field while a virtual keyboard is shown.

[1] a field where you can type.

locksoft commented 3 years ago

Here's the video:

http://www.lemonskin.net/io/[MEDIA]/video/Keyboard.mp4

How you can see, the key press is recognized, but Big Sur doesn't do anything.

MuhammedZakir commented 3 years ago

From what I can see, some keyboard shortcuts are interfering. Have you checked keyboard shortucts in System Preferences?

locksoft commented 3 years ago

Yes, it's what I think too. I've checked keyboard shortcuts and no one has that key combination. I've also tested other keyboards but nothing changes.

MuhammedZakir commented 3 years ago

Maybe global shortucts in some app(s)? Sorry, don't know anything else about this. Can't help you!

P.S. I remember seeing an app which shows your keyboard shortucts - both global and app-specific. You can give it a try. It might show something.

locksoft commented 3 years ago

Ahah, I've found the culprit!

I've recently downloaded an app called "Song Rating" to assign stars to my Apple Music library (in the screenshot I've already removed the shortcuts, and everything works again).

Schermata 2021-09-09 alle 17 29 42

I've started closing all my running apps and starting them one by one.

I'm really sorry I wasted your time, but I really appreciated your help.

Have a nice day, Lock

P.S. I'm just wondering how I've messed up my music library, as I was listening to songs while doing all tests. :P

MuhammedZakir commented 3 years ago

Np. :-D

If your issue is solved, please close this. :-)

locksoft commented 3 years ago

Sure, thanks again.