Standalone keys + One-to-many mappings #247

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
@wwwjfy
Contributor

wwwjfy commented Oct 6, 2016

This is to implement Karabiner's Control_L to Control_L (+when you type Control_L only, send Escape) functionality. It's a temp solution, which can be used until the official one comes out.

Updated (2017.01.06): Added one-to-many mappings, to get one key behaves like multiple keys.

Download the customized build at https://github.com/wwwjfy/Karabiner-Elements/releases

Usage:

{
    "profiles": [
        {
            "name": "Default profile",
            "selected": true,
            "simple_modifications": {
                "caps_lock": "left_control"
            },
            "standalone_keys": {
                "caps_lock": "escape"
            },
            "one_to_many_mappings": {
                "left_control": ["left_control", "left_shift", "left_option", "left_command"]
            }
        }
    ]
}
@omnikron

This comment has been minimized.

Show comment
Hide comment
@omnikron

omnikron Oct 6, 2016

This works absolutely perfectly! I absolutely need this functionality as I remap Caps Lock to Escape (on single press) and Left Control (when held down) so I never have to leave the home row when using vim. I hadn't realised quite how ingrained this was until it broke and I couldn't work any more! Thought I would leave a comment, not only to say thanks but also to make this potentially a bit easier to google.

omnikron commented Oct 6, 2016

This works absolutely perfectly! I absolutely need this functionality as I remap Caps Lock to Escape (on single press) and Left Control (when held down) so I never have to leave the home row when using vim. I hadn't realised quite how ingrained this was until it broke and I couldn't work any more! Thought I would leave a comment, not only to say thanks but also to make this potentially a bit easier to google.

@garymh

This comment has been minimized.

Show comment
Hide comment
@garymh

garymh Oct 7, 2016

7f15552 seems to have broken the functionality for me :( Using the configuration above with this build will change caps lock to control, but not include the escape key at the end:

screen shot 2016-10-07 at 11 28 33 am

garymh commented Oct 7, 2016

7f15552 seems to have broken the functionality for me :( Using the configuration above with this build will change caps lock to control, but not include the escape key at the end:

screen shot 2016-10-07 at 11 28 33 am

@wwwjfy

This comment has been minimized.

Show comment
Hide comment
@wwwjfy

wwwjfy Oct 8, 2016

Contributor

@garymh It works for me. Please try to recompile and reinstall (a easier way is to run make install in src/core/grabber). If possible, try to recompile the one before this to ensure this commit is the reason.

7f15552 should not break this, as this commit changes the key with modifier or not, and should not affect when used alone.

Contributor

wwwjfy commented Oct 8, 2016

@garymh It works for me. Please try to recompile and reinstall (a easier way is to run make install in src/core/grabber). If possible, try to recompile the one before this to ensure this commit is the reason.

7f15552 should not break this, as this commit changes the key with modifier or not, and should not affect when used alone.

@garymh

This comment has been minimized.

Show comment
Hide comment
@garymh

garymh Oct 8, 2016

@wwwjfy Yep, totally right! Thanks and sorry for the confusion!

garymh commented Oct 8, 2016

@wwwjfy Yep, totally right! Thanks and sorry for the confusion!

@erwald erwald referenced this pull request Oct 8, 2016

Closed

Space to Shift_L #228

@zhexuany

This comment has been minimized.

Show comment
Hide comment
@zhexuany

zhexuany Oct 10, 2016

@wwwjfy Your fix is nice; but when I type control_l only instead of typing control_l togehter with other key, it means I want to use esc. For now, control_l seems like waiting for possible future input. Maybe we can short such time that control_l waiting for incoming input.

@wwwjfy Your fix is nice; but when I type control_l only instead of typing control_l togehter with other key, it means I want to use esc. For now, control_l seems like waiting for possible future input. Maybe we can short such time that control_l waiting for incoming input.

@wwwjfy

This comment has been minimized.

Show comment
Hide comment
@wwwjfy

wwwjfy Oct 10, 2016

Contributor

@zhexuany That'd be ideal (Karabiner should be doing that, I can't remember clearly). Current hack is using the simpler way, that esc is sent to system when control_l (left control, right?) is released.
This way I don't have to add a timer, so the code is less "messed". :)

Contributor

wwwjfy commented Oct 10, 2016

@zhexuany That'd be ideal (Karabiner should be doing that, I can't remember clearly). Current hack is using the simpler way, that esc is sent to system when control_l (left control, right?) is released.
This way I don't have to add a timer, so the code is less "messed". :)

@wwwjfy

This comment has been minimized.

Show comment
Hide comment
@wwwjfy

wwwjfy Oct 10, 2016

Contributor

JFYI, I rebased the code on latest master (0.90.47)

Contributor

wwwjfy commented Oct 10, 2016

JFYI, I rebased the code on latest master (0.90.47)

@kibin

This comment has been minimized.

Show comment
Hide comment
@kibin

kibin Oct 10, 2016

@wwwjfy I have the same issue as @garymh did, where can I find src/core/grabber?

kibin commented Oct 10, 2016

@wwwjfy I have the same issue as @garymh did, where can I find src/core/grabber?

@wwwjfy

This comment has been minimized.

Show comment
Hide comment
@wwwjfy

wwwjfy Oct 10, 2016

Contributor

@kibin clone the repo, and it's in root path of the repo.
A easier way is to uninstall and reinstall, which can remove outdated files and kexts (hopefully :).

Contributor

wwwjfy commented Oct 10, 2016

@kibin clone the repo, and it's in root path of the repo.
A easier way is to uninstall and reinstall, which can remove outdated files and kexts (hopefully :).

@kibin

This comment has been minimized.

Show comment
Hide comment
@kibin

kibin Oct 10, 2016

@wwwjfy I’ve uninstalled, reinstalled (esc started working), then updated and it stopped working again. Guess I’ll try to clone repo

kibin commented Oct 10, 2016

@wwwjfy I’ve uninstalled, reinstalled (esc started working), then updated and it stopped working again. Guess I’ll try to clone repo

@zhexuany

This comment has been minimized.

Show comment
Hide comment
@zhexuany

zhexuany Oct 10, 2016

@wwwjfy It worked on your last release but not work in your latest code. Maybe there are something you overlooked.

@wwwjfy It worked on your last release but not work in your latest code. Maybe there are something you overlooked.

@wwwjfy

This comment has been minimized.

Show comment
Hide comment
@wwwjfy

wwwjfy Oct 10, 2016

Contributor

@kibin I see. You have to build it yourself (or someone build it for every new release), because this is a PR, not in mainstream, and when you updated, the hack is gone.

Contributor

wwwjfy commented Oct 10, 2016

@kibin I see. You have to build it yourself (or someone build it for every new release), because this is a PR, not in mainstream, and when you updated, the hack is gone.

@wwwjfy

This comment has been minimized.

Show comment
Hide comment
@wwwjfy

wwwjfy Oct 10, 2016

Contributor

@zhexuany I'm not sure about your case now. I've changed something to suit other cases.
Could you post your action (press which key, release which key), your expected behavior and actual behavior?

Contributor

wwwjfy commented Oct 10, 2016

@zhexuany I'm not sure about your case now. I've changed something to suit other cases.
Could you post your action (press which key, release which key), your expected behavior and actual behavior?

@zhexuany

This comment has been minimized.

Show comment
Hide comment
@zhexuany

zhexuany Oct 10, 2016

@wwwjfy I just download your release from your repo. It works just fine. But the copy I compiled myself from your code under standalone_modifers branch does not work(It works, what I mean is that when I use in in spacemacs, it does not work. When I type control_l, it actually waits for incoming input.). By checking the event viewer, the difference is flagsChanged(I can't remember the exact name). Your old release only has KeyDown and KeyUp.

zhexuany commented Oct 10, 2016

@wwwjfy I just download your release from your repo. It works just fine. But the copy I compiled myself from your code under standalone_modifers branch does not work(It works, what I mean is that when I use in in spacemacs, it does not work. When I type control_l, it actually waits for incoming input.). By checking the event viewer, the difference is flagsChanged(I can't remember the exact name). Your old release only has KeyDown and KeyUp.

@wwwjfy

This comment has been minimized.

Show comment
Hide comment
@wwwjfy

wwwjfy Oct 10, 2016

Contributor

@zhexuany By When I type control_l, do you mean press and release it alone?

I did various fixes and rebase in last week, could you try the latest commit? (committed a few hours ago)

Contributor

wwwjfy commented Oct 10, 2016

@zhexuany By When I type control_l, do you mean press and release it alone?

I did various fixes and rebase in last week, could you try the latest commit? (committed a few hours ago)

@zhexuany

This comment has been minimized.

Show comment
Hide comment
@zhexuany

zhexuany Oct 10, 2016

@wwwjfy That may be the issue. I just pulled from you repo. A lots conflicts.

@wwwjfy That may be the issue. I just pulled from you repo. A lots conflicts.

@wwwjfy

This comment has been minimized.

Show comment
Hide comment
@wwwjfy

wwwjfy Oct 10, 2016

Contributor

It's expected because I did rebase. Just git reset --hard wwwjfy/standalone-modifiers or origin/standalone-modifiers depends on how you cloned~

Contributor

wwwjfy commented Oct 10, 2016

It's expected because I did rebase. Just git reset --hard wwwjfy/standalone-modifiers or origin/standalone-modifiers depends on how you cloned~

@zhexuany

This comment has been minimized.

Show comment
Hide comment
@zhexuany

zhexuany Oct 10, 2016

@wwwjfy Now everything works just fine. Thanks for you patience.

@wwwjfy Now everything works just fine. Thanks for you patience.

@ChrisPenner

This comment has been minimized.

Show comment
Hide comment
@ChrisPenner

ChrisPenner Oct 11, 2016

Looking forward to this! It's one of the main features I used in Karabiner.

Looking forward to this! It's one of the main features I used in Karabiner.

@zhexuany

This comment has been minimized.

Show comment
Hide comment
@zhexuany

zhexuany Oct 11, 2016

@tekezo When will this pull request can be merged into master? To me, @wwwjfy 's approach is pretty nice. Any comments about this?

zhexuany commented Oct 11, 2016

@tekezo When will this pull request can be merged into master? To me, @wwwjfy 's approach is pretty nice. Any comments about this?

@wwwjfy

This comment has been minimized.

Show comment
Hide comment
@wwwjfy

wwwjfy Oct 11, 2016

Contributor

@zhexuany Thanks, but I don't think the hack should be in merged. It's just to be convenient for Sierra users before the official feature implemented. And I created the pull request to be simpler to apply for any one who needs it, not to be merged. :)

Contributor

wwwjfy commented Oct 11, 2016

@zhexuany Thanks, but I don't think the hack should be in merged. It's just to be convenient for Sierra users before the official feature implemented. And I created the pull request to be simpler to apply for any one who needs it, not to be merged. :)

@hndrewaall

This comment has been minimized.

Show comment
Hide comment
@hndrewaall

hndrewaall Oct 11, 2016

@wwwjfy This works really well for me, thanks! However, this seems to break the ctrl-shift-power shortcut for screen locking :( the events look no different in the event viewer, but so long as Elements is running, I can't use this sequence. Any idea why?

@wwwjfy This works really well for me, thanks! However, this seems to break the ctrl-shift-power shortcut for screen locking :( the events look no different in the event viewer, but so long as Elements is running, I can't use this sequence. Any idea why?

@wwwjfy

This comment has been minimized.

Show comment
Hide comment
@wwwjfy

wwwjfy Oct 12, 2016

Contributor

@hndrewaall It's related to #89, not this patch. Event Viewer uses system event to show the pressed keys, so it doesn't mean Karabiner-Elements can handle it currently.

Contributor

wwwjfy commented Oct 12, 2016

@hndrewaall It's related to #89, not this patch. Event Viewer uses system event to show the pressed keys, so it doesn't mean Karabiner-Elements can handle it currently.

@rafi

This comment has been minimized.

Show comment
Hide comment
@rafi

rafi Oct 14, 2016

Karabiner had great timing parameters, specially "Key Overlaid Modifier Timeout" which I always lowered for better experience. Wish xcape worked in macOS.

image

rafi commented Oct 14, 2016

Karabiner had great timing parameters, specially "Key Overlaid Modifier Timeout" which I always lowered for better experience. Wish xcape worked in macOS.

image

@fjl

This comment has been minimized.

Show comment
Hide comment
@fjl

fjl Oct 14, 2016

I second that. I tried this PR to remap space to control and it's not useable without the timeout-based event handling.

fjl commented Oct 14, 2016

I second that. I tried this PR to remap space to control and it's not useable without the timeout-based event handling.

@zhexuany

This comment has been minimized.

Show comment
Hide comment
@zhexuany

zhexuany Oct 14, 2016

@rafi Not sure though. It seems like macOS sierra has changed kernel a lot.

@rafi Not sure though. It seems like macOS sierra has changed kernel a lot.

@MatthewMDavis

This comment has been minimized.

Show comment
Hide comment
@MatthewMDavis

MatthewMDavis Oct 23, 2016

Outstanding. This is what I need to get through until K-Elements is a fully operational death star.

Outstanding. This is what I need to get through until K-Elements is a fully operational death star.

@ssoriche

This comment has been minimized.

Show comment
Hide comment
@ssoriche

ssoriche Oct 23, 2016

@wwwjfy Any chance you'll make an updated release of your branch?

@wwwjfy Any chance you'll make an updated release of your branch?

@wwwjfy

This comment has been minimized.

Show comment
Hide comment
@wwwjfy

wwwjfy Oct 24, 2016

Contributor

updated

Contributor

wwwjfy commented Oct 24, 2016

updated

@oschrenk

This comment has been minimized.

Show comment
Hide comment
@oschrenk

oschrenk Oct 26, 2016

@wwwjfy Can you rebase again?

@wwwjfy Can you rebase again?

@wwwjfy

This comment has been minimized.

Show comment
Hide comment
@wwwjfy

wwwjfy Oct 26, 2016

Contributor

updated.

I've kept watching the commits, and will probably do the rebase every few days, but I don't think it's necessary to do it for every minor version release, as there are no major changes and almost won't affect usage.

If the update prompt bothers you, just write a big number in file version and check updates on Github once in a while.

Contributor

wwwjfy commented Oct 26, 2016

updated.

I've kept watching the commits, and will probably do the rebase every few days, but I don't think it's necessary to do it for every minor version release, as there are no major changes and almost won't affect usage.

If the update prompt bothers you, just write a big number in file version and check updates on Github once in a while.

@mavant

This comment has been minimized.

Show comment
Hide comment
@mavant

mavant Oct 26, 2016

You are a godsend. I did have to cut the code signing segments to get this to build locally, but it's working now. Thank you!

mavant commented Oct 26, 2016

You are a godsend. I did have to cut the code signing segments to get this to build locally, but it's working now. Thank you!

@oschrenk

This comment has been minimized.

Show comment
Hide comment
@oschrenk

oschrenk Oct 26, 2016

Thanks. Combined it with changes from https://github.com/chrisfsmith/Karabiner-Elements/commits/cmd-alt-shift-ctrl-hyper to get most of my old setup back.

Thanks. Combined it with changes from https://github.com/chrisfsmith/Karabiner-Elements/commits/cmd-alt-shift-ctrl-hyper to get most of my old setup back.

@oschrenk oschrenk referenced this pull request Oct 26, 2016

Closed

add hyper key #170

@simonsmith simonsmith referenced this pull request in tekezo/Karabiner Oct 28, 2016

Open

macOS (10.12) compatibility #660

@jondkinney

This comment has been minimized.

Show comment
Hide comment
@jondkinney

jondkinney Oct 29, 2016

@oschrenk Would you be willing to create a build of your combination? I think a lot of people use it that way!

Edit: I went ahead and did it #170 (comment)

jondkinney commented Oct 29, 2016

@oschrenk Would you be willing to create a build of your combination? I think a lot of people use it that way!

Edit: I went ahead and did it #170 (comment)

@oschrenk

This comment has been minimized.

Show comment
Hide comment
@oschrenk

oschrenk Oct 29, 2016

@jondkinney You didn't even give me a chance :)

oschrenk commented Oct 29, 2016

@jondkinney You didn't even give me a chance :)

@jondkinney

This comment has been minimized.

Show comment
Hide comment
@jondkinney

jondkinney Oct 29, 2016

@oschrenk haha, yea, sorry! I was hesitant to have to get setup to compile the dmg, but it was pretty easy.

@oschrenk haha, yea, sorry! I was hesitant to have to get setup to compile the dmg, but it was pretty easy.

@henrebotha

This comment has been minimized.

Show comment
Hide comment
@henrebotha

henrebotha May 23, 2017

@neilgarcia Yes, you can do it with this. Changing the behaviour of Caps Lock doesn't do anything to the behaviour of Ctrl.

@neilgarcia Yes, you can do it with this. Changing the behaviour of Caps Lock doesn't do anything to the behaviour of Ctrl.

@zwpaper

This comment has been minimized.

Show comment
Hide comment
@zwpaper

zwpaper May 23, 2017

@neilgarcia It look like it's hard to set the left control to left control only... but left control work as esc/control is enough for me.
Maybe others can help, sorry

zwpaper commented May 23, 2017

@neilgarcia It look like it's hard to set the left control to left control only... but left control work as esc/control is enough for me.
Maybe others can help, sorry

@neilgarcia

This comment has been minimized.

Show comment
Hide comment
@neilgarcia

neilgarcia May 23, 2017

@henrebotha weird, I mapped my capslock to escape and control when held down and now my ctrl key does not work anymore.

@henrebotha weird, I mapped my capslock to escape and control when held down and now my ctrl key does not work anymore.

@zwpaper

This comment has been minimized.

Show comment
Hide comment
@zwpaper

zwpaper May 23, 2017

@neilgarcia maybe you should post your config file here, and we can find out what happened.

zwpaper commented May 23, 2017

@neilgarcia maybe you should post your config file here, and we can find out what happened.

@neilgarcia

This comment has been minimized.

Show comment
Hide comment
@neilgarcia

neilgarcia May 24, 2017

@zwpaper tried reinstalling karabiner and it works now thanks for the help!

@zwpaper tried reinstalling karabiner and it works now thanks for the help!

@xiongchiamiov

This comment has been minimized.

Show comment
Hide comment
@xiongchiamiov

xiongchiamiov May 24, 2017

I don't understand what one_to_many_mappings does, but getting rid of it allows ctrl to keep acting like ctrl while caps lock does the ctrl/esc business.

I don't understand what one_to_many_mappings does, but getting rid of it allows ctrl to keep acting like ctrl while caps lock does the ctrl/esc business.

@SpectralKH

This comment has been minimized.

Show comment
Hide comment
@SpectralKH

SpectralKH May 24, 2017

I have the problem where hyper-, and hyper-. makes a "sysdiagnose," and this shortcut seems hard to overwrite with methods like BetterTouchTool, because the last key of the shortcut seems to be undetectable for applications. So, is it possible to remap the , and . key only when hyper is pressed?

This was how it could be done with Karabiner: https://sayzlim.net/disable-sysdiagnose-key-combination (Article is from 2013, so may be invalid for the latest version of Karabiner)

SpectralKH commented May 24, 2017

I have the problem where hyper-, and hyper-. makes a "sysdiagnose," and this shortcut seems hard to overwrite with methods like BetterTouchTool, because the last key of the shortcut seems to be undetectable for applications. So, is it possible to remap the , and . key only when hyper is pressed?

This was how it could be done with Karabiner: https://sayzlim.net/disable-sysdiagnose-key-combination (Article is from 2013, so may be invalid for the latest version of Karabiner)

@nicksergeant

This comment has been minimized.

Show comment
Hide comment
@nicksergeant

nicksergeant May 25, 2017

Using this suggested caps-as-ctrl when down and caps-as-esc when tapped, but seems to be a little buggy if you do ctrl-<key> too quickly. You have to hold <key> down for at least 200-300ms while also depressing ctrl for it to register, otherwise it appears to register as <esc> instead of ctrl-<key>. Wondering if there might be an option to configure delays, as there was in the original Karabiner?

nicksergeant commented May 25, 2017

Using this suggested caps-as-ctrl when down and caps-as-esc when tapped, but seems to be a little buggy if you do ctrl-<key> too quickly. You have to hold <key> down for at least 200-300ms while also depressing ctrl for it to register, otherwise it appears to register as <esc> instead of ctrl-<key>. Wondering if there might be an option to configure delays, as there was in the original Karabiner?

@wwwjfy

This comment has been minimized.

Show comment
Hide comment
@wwwjfy

wwwjfy May 25, 2017

Contributor

@nicksergeant search delay on this page, and you'll find examples

Contributor

wwwjfy commented May 25, 2017

@nicksergeant search delay on this page, and you'll find examples

@nicksergeant

This comment has been minimized.

Show comment
Hide comment
@nicksergeant

nicksergeant May 25, 2017

@wwwjfy awesome, thank you!

@wwwjfy awesome, thank you!

@knu knu referenced this pull request in Hammerspoon/hammerspoon Jun 3, 2017

Closed

Using non-modifer key as a modifier #1450

@bosr

This comment has been minimized.

Show comment
Hide comment
@bosr

bosr Jun 6, 2017

Hi, with macOS High Sierra beta out since yesterday, has anyone tried the modified Karabiner-Elements from the current PR?

bosr commented Jun 6, 2017

Hi, with macOS High Sierra beta out since yesterday, has anyone tried the modified Karabiner-Elements from the current PR?

@kennonb

This comment has been minimized.

Show comment
Hide comment
@kennonb

kennonb Jun 6, 2017

@bosr I'm running this PR in High Sierra beta 1 and all appears ok so far. I'm just doing a basic "Caps to HYPER while holding and tapping Caps pressing ESC" modification, but that's still working fine for me.

kennonb commented Jun 6, 2017

@bosr I'm running this PR in High Sierra beta 1 and all appears ok so far. I'm just doing a basic "Caps to HYPER while holding and tapping Caps pressing ESC" modification, but that's still working fine for me.

@bosr

This comment has been minimized.

Show comment
Hide comment

bosr commented Jun 6, 2017

@kennonb thanks!

@samhstn samhstn referenced this pull request in samhstn/My-Config Jun 13, 2017

Closed

Add setup instructions for Sierra #18

@tomislav

This comment has been minimized.

Show comment
Hide comment
@tomislav

tomislav Jun 15, 2017

Happy to report the newest version (0.91.3) now supports complex modifications (no GUI yet). This is my configuration to get the hyper key.

{
    "profiles": [
        {
            "complex_modifications": {
                "rules": [
                    {
                        "manipulators": [
                            {
                                "description": "Change caps_lock to command+control+option.",
                                "from": {
                                    "key_code": "caps_lock",
                                    "modifiers": {
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "left_command",
                                        "modifiers": [
                                            "left_control",
                                            "left_option"
                                        ]
                                    }
                                ],
                                "to_if_alone": [
                                    {
                                        "key_code": "escape"
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    }
                ]
            },
            "name": "Profile",
            "selected": true
        }
    ]
}

Happy to report the newest version (0.91.3) now supports complex modifications (no GUI yet). This is my configuration to get the hyper key.

{
    "profiles": [
        {
            "complex_modifications": {
                "rules": [
                    {
                        "manipulators": [
                            {
                                "description": "Change caps_lock to command+control+option.",
                                "from": {
                                    "key_code": "caps_lock",
                                    "modifiers": {
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "left_command",
                                        "modifiers": [
                                            "left_control",
                                            "left_option"
                                        ]
                                    }
                                ],
                                "to_if_alone": [
                                    {
                                        "key_code": "escape"
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    }
                ]
            },
            "name": "Profile",
            "selected": true
        }
    ]
}
@blackxored

This comment has been minimized.

Show comment
Hide comment
@blackxored

blackxored Jun 15, 2017

Is there a way to preserve the fn while it being mapped to hyper?
I'm trying to get it to work as a hyper key, while working on the volume controls as normal. Can this be achieved via karabiner elements or karabiner+hammerspoon?

Is there a way to preserve the fn while it being mapped to hyper?
I'm trying to get it to work as a hyper key, while working on the volume controls as normal. Can this be achieved via karabiner elements or karabiner+hammerspoon?

@blackxored

This comment has been minimized.

Show comment
Hide comment
@blackxored

blackxored Jun 15, 2017

Answering myself, certainly not the most elegant way by any means, but managed to do it with hammerspoon:

local hyper_fn_keys =  {
  {'f1', 'BRIGHTNESS_DOWN'},
  {'f2', 'BRIGHTNESS_UP'},
  {'f5', 'ILLUMINATION_DOWN'},
  {'f6', 'ILLUMINATION_UP'},
  {'f7', 'PREVIOUS'},
  {'f8', 'PLAY'},
  {'f9', 'NEXT'},
  {'f10', 'MUTE'},
  {'f11', 'SOUND_DOWN'},
  {'f12', 'SOUND_UP'}
}

for i, keymap in ipairs(hyper_fn_keys) do
  hs.hotkey.bind(hyper, keymap[1], function() 
    hs.eventtap.event.newSystemKeyEvent(keymap[2], true):post()
    hs.eventtap.event.newSystemKeyEvent(keymap[2], false):post()
  end)
end

I can't get mission control or launch panel to work but given they've gestures I'm not too concerned.

blackxored commented Jun 15, 2017

Answering myself, certainly not the most elegant way by any means, but managed to do it with hammerspoon:

local hyper_fn_keys =  {
  {'f1', 'BRIGHTNESS_DOWN'},
  {'f2', 'BRIGHTNESS_UP'},
  {'f5', 'ILLUMINATION_DOWN'},
  {'f6', 'ILLUMINATION_UP'},
  {'f7', 'PREVIOUS'},
  {'f8', 'PLAY'},
  {'f9', 'NEXT'},
  {'f10', 'MUTE'},
  {'f11', 'SOUND_DOWN'},
  {'f12', 'SOUND_UP'}
}

for i, keymap in ipairs(hyper_fn_keys) do
  hs.hotkey.bind(hyper, keymap[1], function() 
    hs.eventtap.event.newSystemKeyEvent(keymap[2], true):post()
    hs.eventtap.event.newSystemKeyEvent(keymap[2], false):post()
  end)
end

I can't get mission control or launch panel to work but given they've gestures I'm not too concerned.

@jahamed

This comment has been minimized.

Show comment
Hide comment
@jahamed

jahamed Jun 15, 2017

@tomislav
Awesome that worked for me! Might I ask how you found out about these new options? I'm not seeing any documentation but might have just missed it.

For anyone else who wants to make Caps Lock into Hyper (ctrl, opt, cmd, shift) make this your ~/karabiner/karabiner.json (also update to the beta version under the misc menu in Karabiner)

{
    "global": {
        "check_for_updates_on_startup": true,
        "show_in_menu_bar": true,
        "show_profile_name_in_menu_bar": false
    },
    "profiles": [
        {
            "complex_modifications": {
                "rules": [
                    {
                        "manipulators": [
                            {
                                "description": "Change caps_lock to command+control+option+shift.",
                                "from": {
                                    "key_code": "caps_lock",
                                    "modifiers": {
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "left_shift",
                                        "modifiers": [
                                            "left_command",
                                            "left_control",
                                            "left_option"
                                        ]
                                    }
                                ],
                                "to_if_alone": [
                                    {
                                        "key_code": "escape"
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    }
                ]
            },
            "devices": [],
            "fn_function_keys": {
                "f1": "display_brightness_decrement",
                "f10": "mute",
                "f11": "volume_decrement",
                "f12": "volume_increment",
                "f2": "display_brightness_increment",
                "f3": "mission_control",
                "f4": "launchpad",
                "f5": "illumination_decrement",
                "f6": "illumination_increment",
                "f7": "rewind",
                "f8": "play_or_pause",
                "f9": "fastforward"
            },
            "name": "Default profile",
            "selected": true,
            "simple_modifications": {},
            "standalone_keys": {
            },
            "virtual_hid_keyboard": {
                "caps_lock_delay_milliseconds": 0,
                "keyboard_type": "ansi"
            }
        }
    ]
}

jahamed commented Jun 15, 2017

@tomislav
Awesome that worked for me! Might I ask how you found out about these new options? I'm not seeing any documentation but might have just missed it.

For anyone else who wants to make Caps Lock into Hyper (ctrl, opt, cmd, shift) make this your ~/karabiner/karabiner.json (also update to the beta version under the misc menu in Karabiner)

{
    "global": {
        "check_for_updates_on_startup": true,
        "show_in_menu_bar": true,
        "show_profile_name_in_menu_bar": false
    },
    "profiles": [
        {
            "complex_modifications": {
                "rules": [
                    {
                        "manipulators": [
                            {
                                "description": "Change caps_lock to command+control+option+shift.",
                                "from": {
                                    "key_code": "caps_lock",
                                    "modifiers": {
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "left_shift",
                                        "modifiers": [
                                            "left_command",
                                            "left_control",
                                            "left_option"
                                        ]
                                    }
                                ],
                                "to_if_alone": [
                                    {
                                        "key_code": "escape"
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    }
                ]
            },
            "devices": [],
            "fn_function_keys": {
                "f1": "display_brightness_decrement",
                "f10": "mute",
                "f11": "volume_decrement",
                "f12": "volume_increment",
                "f2": "display_brightness_increment",
                "f3": "mission_control",
                "f4": "launchpad",
                "f5": "illumination_decrement",
                "f6": "illumination_increment",
                "f7": "rewind",
                "f8": "play_or_pause",
                "f9": "fastforward"
            },
            "name": "Default profile",
            "selected": true,
            "simple_modifications": {},
            "standalone_keys": {
            },
            "virtual_hid_keyboard": {
                "caps_lock_delay_milliseconds": 0,
                "keyboard_type": "ansi"
            }
        }
    ]
}
@tomislav

This comment has been minimized.

Show comment
Hide comment
@tomislav

tomislav Jun 15, 2017

@jahamed mostly by reading the commits. Also check out the examples folder. There is also a timeout option for to_if_alone.

@jahamed mostly by reading the commits. Also check out the examples folder. There is also a timeout option for to_if_alone.

@knu

This comment has been minimized.

Show comment
Hide comment
@knu

knu Jun 16, 2017

Finally, 0.91.x has complex_modifications and I've successfully migrated from this fork. The from/to/to_if_alone keys allow you to set up any-to-any mappings and standalone key bindings.

@wwwjfy You really saved my life, thank you for everything you've done!

knu commented Jun 16, 2017

Finally, 0.91.x has complex_modifications and I've successfully migrated from this fork. The from/to/to_if_alone keys allow you to set up any-to-any mappings and standalone key bindings.

@wwwjfy You really saved my life, thank you for everything you've done!

@jhegedus42

This comment has been minimized.

Show comment
Hide comment
@jhegedus42

jhegedus42 Jun 19, 2017

what is this complex modification thing ? what can i do with it ?

what is this complex modification thing ? what can i do with it ?

@SpectralKH

This comment has been minimized.

Show comment
Hide comment
@SpectralKH

SpectralKH Jun 19, 2017

@jhegedus42 A lot. Here's an example:
You remap from "caps_lock" to "left_shift+left_control+left_option+left_command", as well as to "escape" if caps_lock is pressed alone.

You can even choose both mandatory and optional modifier keys for the key combination you're remapping - So you could have shift+caps_lock remap to something.
It's in the beta, which you can get under the "Misc" menu in Karabiner-Elements.

Check out these examples:
https://github.com/tekezo/Karabiner-Elements/blob/master/examples/caps_lock_to_command_control_option_shift.json
https://github.com/tekezo/Karabiner-Elements/blob/master/examples/emacs_key_bindings.json
https://github.com/tekezo/Karabiner-Elements/blob/master/examples/exchange_number_and_symbols.json
https://github.com/tekezo/Karabiner-Elements/blob/master/examples/spacebar_to_shift.json

@jhegedus42 A lot. Here's an example:
You remap from "caps_lock" to "left_shift+left_control+left_option+left_command", as well as to "escape" if caps_lock is pressed alone.

You can even choose both mandatory and optional modifier keys for the key combination you're remapping - So you could have shift+caps_lock remap to something.
It's in the beta, which you can get under the "Misc" menu in Karabiner-Elements.

Check out these examples:
https://github.com/tekezo/Karabiner-Elements/blob/master/examples/caps_lock_to_command_control_option_shift.json
https://github.com/tekezo/Karabiner-Elements/blob/master/examples/emacs_key_bindings.json
https://github.com/tekezo/Karabiner-Elements/blob/master/examples/exchange_number_and_symbols.json
https://github.com/tekezo/Karabiner-Elements/blob/master/examples/spacebar_to_shift.json

@henrebotha

This comment has been minimized.

Show comment
Hide comment
@henrebotha

henrebotha Jun 19, 2017

For those wondering, here is how you get Ctrl to emit Esc when pressed alone in Karabiner Elements 0.91.4:

            "complex_modifications": {
                "rules": [
                    {
                        "manipulators": [
                            {
                                "description": "Change ctrl to esc if pressed alone.",
                                "from": {
                                    "key_code": "left_control",
                                    "modifiers": {
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "left_control"
                                    }
                                ],
                                "to_if_alone": [
                                    {
                                        "key_code": "escape"
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    }
                ]
            }

For those wondering, here is how you get Ctrl to emit Esc when pressed alone in Karabiner Elements 0.91.4:

            "complex_modifications": {
                "rules": [
                    {
                        "manipulators": [
                            {
                                "description": "Change ctrl to esc if pressed alone.",
                                "from": {
                                    "key_code": "left_control",
                                    "modifiers": {
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "left_control"
                                    }
                                ],
                                "to_if_alone": [
                                    {
                                        "key_code": "escape"
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    }
                ]
            }
@davidchambers

This comment has been minimized.

Show comment
Hide comment
@davidchambers

davidchambers Jun 19, 2017

If you're a modern space cadet, try this configuration:

{
  "profiles": [
    {
      "name": "Default profile",
      "selected": true,
      "complex_modifications": {
        "rules": [
          {
            "description": "A Modern Space Cadet (Steve Losh)",
            "manipulators": [
              {
                "type": "basic",
                "from": {"key_code": "caps_lock"},
                "to": [{"key_code": "left_control"}],
                "to_if_alone": [{"key_code": "escape"}]
              },
              {
                "type": "basic",
                "from": {"key_code": "left_shift"},
                "to": [{"key_code": "left_shift"}],
                "to_if_alone": [{"key_code": "9", "modifiers": ["left_shift"]}]
              },
              {
                "type": "basic",
                "from": {"key_code": "right_shift"},
                "to": [{"key_code": "right_shift"}],
                "to_if_alone": [{"key_code": "0", "modifiers": ["right_shift"]}]
              }
            ]
          }
        ]
      }
    }
  ]
}

It feels so good to have shift-parens back! 🎉

If you're a modern space cadet, try this configuration:

{
  "profiles": [
    {
      "name": "Default profile",
      "selected": true,
      "complex_modifications": {
        "rules": [
          {
            "description": "A Modern Space Cadet (Steve Losh)",
            "manipulators": [
              {
                "type": "basic",
                "from": {"key_code": "caps_lock"},
                "to": [{"key_code": "left_control"}],
                "to_if_alone": [{"key_code": "escape"}]
              },
              {
                "type": "basic",
                "from": {"key_code": "left_shift"},
                "to": [{"key_code": "left_shift"}],
                "to_if_alone": [{"key_code": "9", "modifiers": ["left_shift"]}]
              },
              {
                "type": "basic",
                "from": {"key_code": "right_shift"},
                "to": [{"key_code": "right_shift"}],
                "to_if_alone": [{"key_code": "0", "modifiers": ["right_shift"]}]
              }
            ]
          }
        ]
      }
    }
  ]
}

It feels so good to have shift-parens back! 🎉

@ipetepete

This comment has been minimized.

Show comment
Hide comment
@ipetepete

ipetepete Jun 24, 2017

Contributor

Here's an example of Space/FN + IJKL arrow keys...

            {
              "manipulators":[
                  {
                      "description":"Space + L = RIGHT",
                      "type":"basic",
                      "from":{
                          "key_code":"l",
                          "modifiers":{ "mandatory":["fn"]}
                      },
                      "to":[{"key_code":"right_arrow"}]
                  }
              ]
          },{
              "manipulators":[
                  {
                      "description":"Space + K = DOWN",
                      "type":"basic",
                      "from":{
                          "key_code":"k",
                          "modifiers":{ "mandatory":["fn"]}
                      },
                      "to":[{"key_code":"down_arrow"}]
                  }
              ]
          },{
              "manipulators":[
                  {
                      "description":"Space + J = Left",
                      "type":"basic",
                      "from":{
                          "key_code":"j",
                          "modifiers":{ "mandatory":["fn"]}
                      },
                      "to":[{"key_code":"left_arrow"}]
                  }
              ]
          },{
              "manipulators":[
                  {
                      "description":"Space + I = UP",
                      "type":"basic",
                      "from":{
                          "key_code":"i",
                          "modifiers":{ "mandatory":["fn"]}
                      },
                      "to":[{"key_code":"up_arrow"}]
                  }
              ]
          },{
              "manipulators":[
                  {
                    "description":"Space as fn",
                    "type":"basic",
                    "from":{
                        "key_code":"spacebar",
                        "modifiers":{"optional":["any"]}
                    },
                      "to":[{"key_code":"fn"}],
                    "to_if_alone":[{"key_code":"spacebar"}]
                  }
              ]
          }

Pull request here: #794

Contributor

ipetepete commented Jun 24, 2017

Here's an example of Space/FN + IJKL arrow keys...

            {
              "manipulators":[
                  {
                      "description":"Space + L = RIGHT",
                      "type":"basic",
                      "from":{
                          "key_code":"l",
                          "modifiers":{ "mandatory":["fn"]}
                      },
                      "to":[{"key_code":"right_arrow"}]
                  }
              ]
          },{
              "manipulators":[
                  {
                      "description":"Space + K = DOWN",
                      "type":"basic",
                      "from":{
                          "key_code":"k",
                          "modifiers":{ "mandatory":["fn"]}
                      },
                      "to":[{"key_code":"down_arrow"}]
                  }
              ]
          },{
              "manipulators":[
                  {
                      "description":"Space + J = Left",
                      "type":"basic",
                      "from":{
                          "key_code":"j",
                          "modifiers":{ "mandatory":["fn"]}
                      },
                      "to":[{"key_code":"left_arrow"}]
                  }
              ]
          },{
              "manipulators":[
                  {
                      "description":"Space + I = UP",
                      "type":"basic",
                      "from":{
                          "key_code":"i",
                          "modifiers":{ "mandatory":["fn"]}
                      },
                      "to":[{"key_code":"up_arrow"}]
                  }
              ]
          },{
              "manipulators":[
                  {
                    "description":"Space as fn",
                    "type":"basic",
                    "from":{
                        "key_code":"spacebar",
                        "modifiers":{"optional":["any"]}
                    },
                      "to":[{"key_code":"fn"}],
                    "to_if_alone":[{"key_code":"spacebar"}]
                  }
              ]
          }

Pull request here: #794

@aaronjensen

This comment has been minimized.

Show comment
Hide comment
@aaronjensen

aaronjensen Jul 3, 2017

Is fn the only "custom modifier" we get?

Is fn the only "custom modifier" we get?

@ipetepete

This comment has been minimized.

Show comment
Hide comment
@ipetepete

ipetepete Jul 3, 2017

Contributor

@aaronjensen No, you can change fn to whatever modifier you want, or combination of modifiers. The original has been updated and has an example similar to this one but they used Sas the modifier. See the examples here: https://github.com/tekezo/Karabiner-Elements/tree/master/examples

Contributor

ipetepete commented Jul 3, 2017

@aaronjensen No, you can change fn to whatever modifier you want, or combination of modifiers. The original has been updated and has an example similar to this one but they used Sas the modifier. See the examples here: https://github.com/tekezo/Karabiner-Elements/tree/master/examples

@aaronjensen

This comment has been minimized.

Show comment
Hide comment
@aaronjensen

aaronjensen Jul 3, 2017

Sorry, I should have been more clear. In karabiner you could create custom modifiers. Fn is not actually custom, it is built in. Furthermore, I believe it is flagged along with every key press if you have the use f keys as f keys checked, making it not useful in those instances. If I were to use fn as an additional modifier, to say, make my home row produce brackets, I could not then also use f keys as f keys afaict.

That said, these additions are huge as they are and I'm looking forward to what comes next. If there is a way to have custom modifiers that I don't know of then great, otherwise I'll probably open a new issue if there isn't one already.

Sorry, I should have been more clear. In karabiner you could create custom modifiers. Fn is not actually custom, it is built in. Furthermore, I believe it is flagged along with every key press if you have the use f keys as f keys checked, making it not useful in those instances. If I were to use fn as an additional modifier, to say, make my home row produce brackets, I could not then also use f keys as f keys afaict.

That said, these additions are huge as they are and I'm looking forward to what comes next. If there is a way to have custom modifiers that I don't know of then great, otherwise I'll probably open a new issue if there isn't one already.

@aaronjensen

This comment has been minimized.

Show comment
Hide comment
@aaronjensen

aaronjensen Jul 3, 2017

Furthermore, I believe it is flagged along with every key press if you have the use f keys as f keys checked

Seems I was mistaken on this, I don't remember when I saw that...

Furthermore, I believe it is flagged along with every key press if you have the use f keys as f keys checked

Seems I was mistaken on this, I don't remember when I saw that...

@lambdalisue

This comment has been minimized.

Show comment
Hide comment
@lambdalisue

lambdalisue Jul 23, 2017

This is a memo for anyone who had problems with complex_modifications

I could not make the following with complex_modifications but standalone_keys

  • lang1 is left_shift or return_or_enter when pressed alone (complex_modifications or standalone_keys)
  • right_shift is lang1 (simple_modifications)

With complex_modifications, it seems the mapping applied recursively. So the right_shift actually became left_shift or return_or_enter. So I don't have any way to hit lang1 with complex_modifications but standalone_keys. I hope that the original complex_modifications behave like standalone_keys ...

This is a memo for anyone who had problems with complex_modifications

I could not make the following with complex_modifications but standalone_keys

  • lang1 is left_shift or return_or_enter when pressed alone (complex_modifications or standalone_keys)
  • right_shift is lang1 (simple_modifications)

With complex_modifications, it seems the mapping applied recursively. So the right_shift actually became left_shift or return_or_enter. So I don't have any way to hit lang1 with complex_modifications but standalone_keys. I hope that the original complex_modifications behave like standalone_keys ...

@tekezo

This comment has been minimized.

Show comment
Hide comment
@tekezo

tekezo Sep 11, 2017

Owner

Thank you for the fork!
Karabiner-Elements supports complex remapping rules since v0.91.2.
Thus, I close this PR.

Owner

tekezo commented Sep 11, 2017

Thank you for the fork!
Karabiner-Elements supports complex remapping rules since v0.91.2.
Thus, I close this PR.

@tekezo tekezo closed this Sep 11, 2017

samhstn added a commit to samhstn/My-Config that referenced this pull request Sep 21, 2017

@samhstn samhstn referenced this pull request in samhstn/My-Config Sep 21, 2017

Merged

Karabiner Elements updated #40

nathanaelkane added a commit to nathanaelkane/dotfiles that referenced this pull request Nov 14, 2017

@krasnovpro

This comment has been minimized.

Show comment
Hide comment
@krasnovpro

krasnovpro Jan 18, 2018

I need to map "button3 -> space+button1". How can I do this?

I need to map "button3 -> space+button1". How can I do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment