Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reassign § key to ~ in version 12 #1365

Closed
demalexx opened this issue Apr 20, 2018 · 19 comments
Closed

Reassign § key to ~ in version 12 #1365

demalexx opened this issue Apr 20, 2018 · 19 comments
Labels

Comments

@demalexx
Copy link

demalexx commented Apr 20, 2018

Prior to version 12 I just chose ISO virtual keyboard and that's all I need to get "~" (which is next to left shift) on proper place - instead of "§" (which is below Esc). Since version 12 there is no such setting. I tried to change country code, selected ISO in Keyboard Setup Assistant, but still I need to use "~" key next to left shift to get my tilde.
And I don't have System Preferences > Keyboard > Change Keyboard Type... button.
Is it possible to have same behavior in version 12 as in older version?

@cotfas
Copy link

cotfas commented Apr 20, 2018

screenshot at apr 15 5-28-00 pm

I`m not sure, but maybe it can help you, I have the Karabinier 12, and I was able to switch ~ with § and left shift.

@dpwrussell
Copy link

dpwrussell commented Apr 21, 2018

I've just hit this myself. I'm not sure why it's happening, but on my ISO keyboard §± and `~are reversed without any simple modifications in karabiner-elements.

When I push §±:

eventType:key_down        code:0x64       name:non_us_backslas misc:
eventType:key_up          code:0x64       name:non_us_backslas misc:

When I push `~:

eventType:key_down        code:0x35       name:grave_accent_an misc:
eventType:key_up          code:0x35       name:grave_accent_an misc:

When Karabiner is not running, the keys output the correct symbols for an ISO (in my case UK) keyboard.

As others have said, it's not possible to Change Keyboard Type if either an external keyboard isn't attached or Karabine Elements is not running. If I do this when Karabiner Elements is running and let it autodetect by pressing the button to the right of the shift key, the mapping is still incorrect.

I was able to circumvent this by tricking the autodetect when using Change Keyboard Type. I instead press the §± key when autodetecting and the detection results in a correctly mapped keyboard.

Karabiner Elements version: 12.0.0

My intuition about how Karabiner Elements works is that it presents the mapped keyboard to the OS as a device (which is why the Keyboard Type button appears when Karabiner is launched which normally only appears for external keyboards) and that somehow these keys have got muddled in that simulated device.

Thanks. Karabiner is awesome!

@dpwrussell
Copy link

dpwrussell commented Apr 23, 2018

Actually, this isn't as easy to fix as I thought. I was using my laptop on its own, then plugged it back into the external keyboard, the keys had gotten switched back over and when I went to Change Keyboard Type and pressed a key on my external keyboard it said this:
screen shot 2018-04-23 at 14 48 15

I'm guessing this problem is due to the way in which I fixed the problem perhaps, but still, it means the problem is slightly worse than I originally thought.

Note: The key mapping on my laptop keyboard are still correctly mapped.

@e-gaulue
Copy link

e-gaulue commented Apr 24, 2018

+1 with French keyboard

@luketsd
Copy link

luketsd commented Apr 25, 2018

+1, I thought it was maybe because I had previously plugged in a PC layout keyboard, and then gone back to a mac layout keyboard

@e-gaulue
Copy link

e-gaulue commented May 2, 2018

So, to sum it up. Since version 12:

  1. some users have swapped keys when Karabiner is running (for me French keyboard: right key of left shift exchanged with above key of tabulation).
  2. on Karabiner installation, we had the "Change keyboard type" on Keyboard settings and the Keyboard Setup Assistant opened. We have set this (often to ISO in Europe)
  3. then with time, can't say exactly when, the "Change keyboard type" button has disappeared.

Solution I've tested is:
defaults read /Library/Preferences/com.apple.HIToolbox.plist AppleEnabledInputSources then get the KeyboardLayout ID and put it in the Virtual Keyboard tab or Karabiner (was 0 before). Then Keyboard Setup Assistant opens again. Follow it.

But after a while it has gone again. I found something else: read bellow.

@demalexx
Copy link
Author

demalexx commented May 5, 2018

@e-gaulue didn't work for me. So I created config to put tilda to correct location:

{
    "title": "My rules",
    "rules": [
        {  
            "description": "Fix tilda location (from next from Shift to above Tab)",
            "manipulators": [
                {
                    "type": "basic",
                    "from": {
                        "key_code": "grave_accent_and_tilde",
                        "modifiers": {
                            "optional": [
                                "any"
                            ]
                        }
                    },
                    "to": [
                        {
                            "key_code": "non_us_backslash"
                        }
                    ]
                },
                {
                    "type": "basic",
                    "from": {
                        "key_code": "non_us_backslash",
                        "modifiers": {
                            "optional": [
                                "any"
                            ]
                        }
                    },
                    "to": [
                        {
                            "key_code": "grave_accent_and_tilde"
                        }
                    ]
                }
            ]
        }
    ]
}

@j0hnsmith
Copy link

A year or more ago I had § & ~ switched on a UK apple keyboard (bluetooth I think), the normal keyboard on my laptop was fine. This fixed it for me, well looking at it now maybe only half fixed it as I don't use the § key.

image

@e-gaulue
Copy link

After a while, my trick as failed. But, here is a new one that leaves you reset your keyboard type to your need, all the time (with or without button on OSX keyboard settings).

First, I checked my keyboard type :
defaults read /Library/Preferences/com.apple.keyboardtype "keyboardtype"

Answer for me was :

{
    "10203-5824-0" = 43;
}

You can have more than one: that's all the associations OS X has seen for your keyboard depending to its country code (the last digit -0 is the same as the Country Code in the Virtual keyboard tab of Karabiner-Elements).

So, as you can see my value for Country Code 0 is 43. In this case, the button to change keyboard type in OS X settings is hidden or has no effect when clicking on it.

In my case, I need 41. So I've changed the value this way: sudo defaults write /Library/Preferences/com.apple.keyboardtype "keyboardtype" -dict "10203-5824-0" 41 but it works with anything other than 43. That's just to say something has changed.

As far as I understood, we have just modified the settings in the file, not in the computer memory. To make it works, we need to (don't ask me why) restart karabiner. Then you can click change keyboard type in the OSX keyboard settings.

In this case, the assistant opens again and leaves you choose your keyboard type. If you don't restart Karabiner, it does not. Looks like Karabiner keeps a lock on this setting.

BEWARE: Changing my keyboard type again from OS X settings got me back to 43 value, each time I did it. In this case, you just have to redo this trick again.

To sum it up:

  1. Change value for your keyboard in /Library/Preferences/com.apple.keyboardtype to anything different than 43
  2. Restart Karabiner
  3. Change your keyboard type in the OSX settings

Regards,

@tplesnar
Copy link

tplesnar commented Jul 9, 2018

I believe I'm having the same issue. I tried every solution regarding macos tools proposed in this thread without success, and finally setting on a simple modification of the keys 0x64 and 0x35 for my keyboard connected in usb to my mac (ISO). My internal MBA always sends 0x35 when pressing the key left to right shift, whereas the connected USB starts sending 0x35 and then switches to 0x64 depending on deconnection/reconnection or reboots. Quiting karabiner has no effect on this behavior

While looking at event viewer > variables:

    "frontmost_application": {
        "bundle_identifier": "com.googlecode.iterm2",
        "file_path": "/Applications/iTerm.app/Contents/MacOS/iTerm2"
    },
    "input_source_identifiers": {
        "input_mode_id": "",
        "input_source_id": "com.apple.keylayout.Swedish-Pro",
        "language": "sv"
    },
    "keyboard_type": "ansi",
    "variables": {}
}

"keyboard_type": "ansi", should be ISO I think.

@stale
Copy link

stale bot commented Sep 7, 2018

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.

@stale stale bot added the stale label Sep 7, 2018
@dpwrussell
Copy link

I don't think it is fixed yet.

@stale
Copy link

stale bot commented Nov 7, 2018

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.

@sveinugu
Copy link

sveinugu commented Oct 4, 2019

Still not fixed, as far as I can see!

@rogual
Copy link

rogual commented Feb 3, 2020

This bug still happens for me on macOS 10.14.6 with Karabiner-Elements 12.9.0.

@MTCoster
Copy link

Be very careful with the proposed fix above!

On my system:

➜ defaults read /Library/Preferences/com.apple.keyboardtype "keyboardtype"
{
    "10203-5824-0" = 43;
    "28673-4389-0" = 41;
    "45081-1133-0" = 41;
    "50475-1133-0" = 40;
    "9267-6551-0" = 41;
}

When using the command above, the remaining entries are overwritten:

➜ defaults write /Library/Preferences/com.apple.keyboardtype "keyboardtype" -dict "10203-5824-0" 41
➜ defaults read /Library/Preferences/com.apple.keyboardtype "keyboardtype"
{
    "10203-5824-0" = 41;
}

This caused my Mac to get stuck in a login loop, where the system crashed to the login screen every time Karabiner-Elements auto-loaded at login.

If anyone else hit this problem, restart while holding R at boot to enter recovery mode. Delete (or rename) the keyboardtype plist file from the mounted Macintosh HD:

➜ rm -f /Volumes/Macintosh\ HD/Library/Preferences/com.apple.keyboardtype.plist

Then reboot. macOS will regenerate the missing file at login, after prompting with the Keyboard Setup Assistant:

➜ defaults read /Library/Preferences/com.apple.keyboardtype "keyboardtype"
{
    "10203-5824-0" = 41;
    "45081-1133-0" = 41;
    "9267-6551-0" = 41;
}

@coredevel
Copy link

coredevel commented Nov 17, 2021

@MTCoster I had exactly the same issue and a similar output to yours running the defaults read cmd. In fact, I completely forgot Karabiner Elements was installed and have been scratching my head for days as to why the backtick key was swapped with +/- on a recent European/UK MBP retina device, after trying several times with keyboard setup with no success. Then I remembered I tried an external keyboard last week and needed some modifiers...

I've managed to fix this now, with Karabiner 14.2 (just ran an update today, but that alone didn't solve it). Running the defaults read cmd the below was output:

> defaults read /Library/Preferences/com.apple.keyboardtype "keyboardtype"
{
    "10203-5824-0" = 41;
    "2-7247-0" = 41;
    "64097-9639-0" = 41;
    "8467-16700-0" = 43;
}

I observed that when quitting KE the keyboard starts working as expected, and based on the above output I assumed the country code I was looking for was '41', so in KE > Preferences > Virtual Keyboard I simply entered that value there (rather than updating underlying OS X preferences manually):

image

After entering the value:

  1. press the Enter/Return key on the keyboard
  2. the keyboard setup assistant opens
  3. follow the process as normal
  4. close KE Preferences
  5. hey presto everything works as expected

When running the defaults read cmd again there's now a new entry:

{
    "10203-5824-0" = 41;
    "10203-5824-41" = 43; <--- new entry
    "2-7247-0" = 41;
    "64097-9639-0" = 41;
    "8467-16700-0" = 43;
}

I don't know the mechanics of how the kbd prefs work so can't explain why, obviously some kind of mapping, but it works :D Hope that helps!

@davepivonka
Copy link

davepivonka commented Feb 27, 2023

@MTCoster Oh well, I tried the solution before seeing your reply. Luckily, now it "only" crashed my computer whenever I started typing on the keyboard, so when I realised it after a few crashes, I had time to turn Karabiner Elements off with my trackpad. I have also noticed that my browser got completely reset so now I need to log in back to all accounts - hopefully, no other apps were affected, the browser was not even in the foreground. Thanks for letting us know the fix to the fix though haha

@dmayle
Copy link

dmayle commented Feb 8, 2024

I ran into this issue, and had some notes for if anyone else comes across it.

First, they keys in the plist, like 4369-4369-0 can be read in the System Information app by finding the keyboard under USB. I have the Matias Ergo Pro, which is "Product ID: 0x1111" "Vendor ID: 0x1111". 0x1111 converted from hex to decimal is 4369.

Second, using defaults write, you want normally want to use -dict-add, which allows you to overwrite a single key/value in that dict.

Finally, in my case, changing the value to 41 for ISO on my keyboard caused WindowServer to crash every time I changed the value. I decided, instead, to delete just the single entry for my keyboard with the value 43.

There is no -dict-del, so instead you have to use -dict and specify every single OTHER key value pair except for the one you want to delete.

For example:

sudo defaults write /Library/Preferences/com.apple.keyboardtype keyboardtype -dict 20548-12815-0 40 49288-1133-0 40 55-5426-0 42 73-9610-0 40

After deleting the value, I rebooted and plugged in my keyboard, which caused the "Detect Keyboard Type" window to come up. Choosing ISO there caused the value to be correctly set to 41.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests