Open kbirger opened 3 years ago
+1
It kind of seems like Karabiner conflates input devices because in the UI, it looks like some devices may report as having both keyboard and mouse functionality, which is fair enough (bluetooth combo keyboard/touchpad devices? Mice with Macros?), but it almost seems like mouse movement comes in through the same channel and cancels the key-down event
I have a Lenovo Bluetooth keyboard/mouse combo that shares a single dongle. The shortcut cancels when:
Here's my rule:
"description": "Ctrl + Tab to Cmd + Tab",
"manipulators": [
{
"from": {
"key_code": "tab",
"modifiers": {
"mandatory": [
"left_control"
]
}
},
"to": [
{
"key_code": "tab",
"modifiers": [
"left_gui"
]
}
],
"type": "basic"
}
]
It'd be just lovely to get some acknowledgement of this issue 🤔 . Perhaps if one of the maintainers knows the cause, it would encourage someone else to step up and fix it with a PR.
Same problem here.
Any workaround possible for this?
Having this issue as well, haven't tried it myself yet, but this thread seems to have some promise https://github.com/pqrs-org/Karabiner-Elements/issues/281.
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.
I'm still affected by this issue, so the stale label is incorrect.
this is basically the same as https://github.com/pqrs-org/Karabiner-Elements/issues/2304 which means the first report of this bug is older than two years now, both tickets are still open. so I guess waiting for a fix is a bad idea. may I ask what workarounds or alternatives people have found for their key mapping?
next on my list would be trying to write my mappings into ~/Library/KeyBindings/DefaultKeyBinding.dict and if that doesn't work I'd probably try the hidutil approach, but compared to such an easy solution as karabiner it feels tiresome and clunky :(
@d-t-o have you found any workaround?
@franco-ruggeri yes, but it's most likely not the reply you want to hear: I use a DefaultKeyBinding.dict, a org.custom.keyboard-remap.plist (one for fixed rebinds (ctrl<->alt), one for combinations(end-key to end-of-line)), a self-defined keyboard layout made with ukelele (to enter such 'complicated' things as '~' or have my '@' on altgr+q) and AltTab from the app store to rebind my window switcher to alt-tab instead of ctrl-tab.
the only mapping I'm using Karabiner for, is remapping ctrl-tab to ctrl-shift-tab as ctrl-tab can't be rebound through other ways as it's reserved for the macos app switcher. since I don't need an app switcher on ctrl-tab if I have a window switcher on alt-tab, I had to free that combination up somehow. Doing this with Karabiner does not trigger the mouse-is-treated-as-input-bug we're talking about in here, but it's way less convenient than it could have been with doing everything in Karabiner.
@d-t-o Hello, I'm newcomer to macos and I'm trying to achieve what you did, could you please give some resources about editing that dict files?
Having this issue as well, haven't tried it myself yet, but this thread seems to have some promise #281.
This workarounds fixes it for me. Add both in karabiner.json:
{
"description": "Sticky Alt to Cmd Variable",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_alt",
"modifiers": {
"optional": ["any"]
}
},
"to": [
{
"set_variable": {
"name": "left_alt pressed",
"value": 1
}
},
{
"key_code": "left_command"
}
],
"to_after_key_up": {
"set_variable": {
"name": "left_alt pressed",
"value": 0
}
}
}
]
},
{
"description": "Alt+Tab to change app",
"manipulators": [
{
"conditions": [
{
"name": "left_alt pressed",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "tab",
"modifiers": {
"mandatory": ["option"],
"optional": ["any"]
}
},
"to": [
{
"key_code": "tab",
"modifiers": [
"left_command"
]
}
],
"type": "basic"
}
]
}
This works, but it also overrides other ALT + *
sequences, like ALT + LEFT
which is supposed to move the caret back a word, and ALT + delete
which is supposed to remove a word.
Same issue here. Mapping Cmd+Tab
to Option+Tab
works ok, but then if I move the mouse or press other modifiers, the mapping stops working. Example: Press Cmd+Tab
to trigger switching application using AltTab shortcut Option+Tab
. Works great. But if I press Shift
to switch to previous application, the complex_modification stops working. Same if I move my mouse.
I tried to work around it by adding the rule Cmd+LeftShift
-> Option+LeftShift
to allow switching to previous app and it works, but not only in "AltTab" application switch popup but also in all other applications. I tried to add frontmost_application_if
with "AltTab" bundle_identifier com.lwouis.alt-tab-macos
but it only works for actual "AltTab" app but not for popup. Karabiner-EventViewer didn't output the bundle_identifier for AltTab popup so I'm stuck.
My code:
{
"description": "Map <Cmd-Tab> to <M-Tab> for AltTab app",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "tab",
"modifiers": {
"mandatory": ["left_command"],
"optional": ["any"]
}
},
"to": [
{
"key_code": "tab",
"modifiers": ["left_option"]
}
]
},
{
"type": "basic",
"conditions": [
{
"bundle_identifiers": ["com.lwouis.alt-tab-macos"],
"file_paths": ["/Applications/AltTab.app/Contents/MacOS/AltTab"],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "left_shift",
"modifiers": {
"mandatory": ["left_command"]
}
},
"to": [
{
"key_code": "left_shift",
"modifiers": ["left_option"]
}
]
}
]
}
If there is a way to find out the bundle_identifier for "AltTab" popup switcher, then my issue will be solved (though moving mouse still would mess everything).
Meet Same issue. I Mapping Cmd+Tab to Ctrl+Tab , it works ok, but then if I move the mouse, the mapping stops working. use EventViewer to check what happened, below is log:
[
{
"type": "down",
"name": {"key_code":"left_command"},
"usagePage": "7 (0x0007)",
"usage": "227 (0x00e3)",
"misc": "flags left_command"
},
{
"type": "down",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_command"
},
//press tab, it start map cmd as ctrl
{
"type": "down",
"name": {"key_code":"left_control"},
"usagePage": "7 (0x0007)",
"usage": "224 (0x00e0)",
"misc": "flags left_command,left_control"
},
{
"type": "up",
"name": {"key_code":"left_command"},
"usagePage": "7 (0x0007)",
"usage": "227 (0x00e3)",
"misc": "flags left_control"
},
{
"type": "down",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_control"
},
{
"type": "up",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_option"
},
{
"type": "up",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_control"
},
{
"type": "down",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_option"
},
{
"type": "down",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_control"
},
{
"type": "up",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_option"
},
{
"type": "up",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_control"
},
// move mouse, it release ctrl and press cmd
{
"type": "up",
"name": {"key_code":"left_control"},
"usagePage": "7 (0x0007)",
"usage": "224 (0x00e0)",
"misc": ""
},
{
"type": "down",
"name": {"key_code":"left_command"},
"usagePage": "7 (0x0007)",
"usage": "227 (0x00e3)",
"misc": "flags left_command"
},
{
"type": "down",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_option"
},
//press tab again, it map cmd as ctrl again.
{
"type": "down",
"name": {"key_code":"left_control"},
"usagePage": "7 (0x0007)",
"usage": "224 (0x00e0)",
"misc": "flags left_command,left_control"
},
{
"type": "up",
"name": {"key_code":"left_command"},
"usagePage": "7 (0x0007)",
"usage": "227 (0x00e3)",
"misc": "flags left_control"
},
{
"type": "down",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_control"
},
{
"type": "up",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_option"
},
{
"type": "up",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_control"
},
{
"type": "down",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_option"
},
{
"type": "down",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_control"
},
{
"type": "up",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_option"
},
{
"type": "up",
"name": {"key_code":"tab"},
"usagePage": "7 (0x0007)",
"usage": "43 (0x002b)",
"misc": "flags left_control"
},
{
"type": "up",
"name": {"key_code":"left_option"},
"usagePage": "7 (0x0007)",
"usage": "226 (0x00e2)",
"misc": ""
},
{
"type": "up",
"name": {"key_code":"left_control"},
"usagePage": "7 (0x0007)",
"usage": "224 (0x00e0)",
"misc": ""
},
]
do not know why move mouse will press cmd again.
Maybe it help, sorry for my English. I use windows keyboard, therefore I have on the left side "Ctrl", "Command" (or "Win"), "Option" (or "Alt"). I think this trick work only with app where you can change shortcuts.
I want copy/paste like in windows therefore I switch "Ctrl" to "Command" and "Command" to "Ctrl" in settings "Simple Modification" and I add another key to this settings "f16" to "f16" (I don't have this key in my keyboard, but I explain it later, you can add unused key or add not existing key like I).
Now copy/paste work like in windows, but switching tabs in browser like in windows not working because "Ctrl" now is "Cmd" that is incorrect position in keyboard. In windows I can switch tabs in browser like this "Ctrl+(Shift)+Tab", therefore in macOs I need to change it like this "Cmd+(Shift)+Tab". See code below:
{
"description": "Cmd+(Shift)+Tab => Ctrl+(Shift)+Tab (Switch tabs) (Add condition for app where you have problem add custom shortcuts in settings (for example see VSCode Cmd+F16))",
"manipulators": [{
"conditions": [{
"bundle_identifiers": [
"^com\\.microsoft\\.VSCode"
],
"type": "frontmost_application_unless"
}],
"from": {
"key_code": "tab",
"modifiers": {
"mandatory": [
"command"
],
"optional": [
"shift",
"caps_lock"
]
}
},
"to": [{
"key_code": "tab",
"modifiers": [
"control"
]
}],
"type": "basic"
},
{
"from": {
"key_code": "tab",
"modifiers": {
"mandatory": [
"command"
],
"optional": [
"shift",
"caps_lock"
]
}
},
"to": [{
"key_code": "f16",
"modifiers": [
"command"
]
}],
"type": "basic"
}
]
}
You can see the condition for VSCode and f16 key. f16 need in VSC to change shortcuts. Because when using "Cmd+(Shift)+Tab" and moving mouse while holding "Cmd" or pressing "Shift" cancels the task selection (like in above comments) therefore I add not existing key and change VSC shortcuts to switch tabs. So I modify combination "Cmd+tab" to "Cmd+f16" only in VSC. The order in "manipulators" elements is required. Find and change shortcut "ctrl+tab" and press "cmd+tab" it writes "cmd+f16". Find "ctrl+shift+tab" and press "cmd+shift+tab" it writes "shift+cmd+f16".
Or just add shortcuts direct to keybindings.json.
My keybindings.json looks:
[
{
"key": "cmd+f16",
"command": "workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup",
"when": "!activeEditorGroupEmpty"
},
{
"key": "ctrl+tab",
"command": "-workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup",
"when": "!activeEditorGroupEmpty"
},
{
"key": "cmd+f16",
"command": "workbench.action.quickOpenNavigateNextInEditorPicker",
"when": "inEditorsPicker && inQuickOpen"
},
{
"key": "ctrl+tab",
"command": "-workbench.action.quickOpenNavigateNextInEditorPicker",
"when": "inEditorsPicker && inQuickOpen"
},
{
"key": "shift+cmd+f16",
"command": "workbench.action.quickOpenLeastRecentlyUsedEditorInGroup",
"when": "!activeEditorGroupEmpty"
},
{
"key": "ctrl+shift+tab",
"command": "-workbench.action.quickOpenLeastRecentlyUsedEditorInGroup",
"when": "!activeEditorGroupEmpty"
},
{
"key": "shift+cmd+f16",
"command": "workbench.action.quickOpenNavigatePreviousInEditorPicker",
"when": "inEditorsPicker && inQuickOpen"
},
{
"key": "ctrl+shift+tab",
"command": "-workbench.action.quickOpenNavigatePreviousInEditorPicker",
"when": "inEditorsPicker && inQuickOpen"
}
]
Don't forgot about "conditions" in code above. For VSC I add "^com\.microsoft\.VSCode". This condition means use "Cmd+Tab" everywhere except VSC, and last element in "manipulators" intended for apps (in my case VSC) where you have problem and where you can change shortcuts.
I am also having this problem with Karabiner 14.13.0 and OSX 13.6
Still a problem here with up to date software too. Fixing this would help a lot of people switching from Windows to Mac or in need to regularly use both Windows and Mac computers.
This bug is really annoying, so while I can't offer much I'd be willing to pay a bounty of 30€ or 30USD to the person fixing this bug in an official release of Karabiner Elements.
This bug is really annoying, so while I can't offer much I'd be willing to pay a bounty of 30€ or 30USD to the person fixing this bug in an official release of Karabiner Elements.
Thanks to vandemjh's comments on https://github.com/pqrs-org/Karabiner-Elements/issues/281 I finally have this working properly. Recommend you read his comments for explanation, but basically we use two rules.
The first rule "convert[s] the left_alt
press into a left_command
press with the side effect of setting a variable, left_alt pressed
to 1 while left_alt
is being pressed (and zero otherwise)" (which lets us use alt-tab without removing the ability to use alt in other keycombos). So, the first rule:
{
"description": "Sticky Alt to Cmd Variable",
"manipulators": [
{
"from": {
"key_code": "left_alt",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"set_variable": {
"name": "left_alt pressed",
"value": 1
}
},
{
"key_code": "left_command"
}
],
"to_after_key_up": {
"set_variable": {
"name": "left_alt pressed",
"value": 0
}
},
"type": "basic"
}
]
}
Then we can create a simple Ctrl+Tab => Cmd+Tab rule that takes the left_alt pressed
variable and uses it as a condition:
{
"description": "Ctrl+Tab => Cmd+Tab (Switch application) using Sticky Alt to Cmd Variable",
"manipulators": [
{
"conditions": [
{
"name": "left_alt pressed",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "tab",
"modifiers": {
"mandatory": [
"command"
],
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "tab",
"modifiers": [
"left_command"
]
}
],
"type": "basic"
}
]
}
Thanks to vandemjh's comments on #281 I finally have this working properly. Recommend you read his comments for explanation, but basically we use two rules.
This works for me!
Sorry, seems I missed mentioning an important piece of information: Since I also often need to use Windows computers I want to keep the keyboard layout as similar as possible. To that end, I've switched left cmd and left ctrl globally using simple modifications. Additionally I have the following rule to switch cmd-tab with ctrl-tab (and optional shift):
{
"description": "Swap \"command + tab\" with \"control + tab\" optional shift.",
"manipulators": [
{
"from": {
"key_code": "tab",
"modifiers": {
"mandatory": [
"command"
],
"optional": [
"shift"
]
}
},
"to": [
{
"key_code": "tab",
"modifiers": [
"control"
]
}
],
"type": "basic"
},
{
"from": {
"key_code": "tab",
"modifiers": {
"mandatory": [
"control"
],
"optional": [
"shift"
]
}
},
"to": [
{
"key_code": "tab",
"modifiers": [
"command"
]
}
],
"type": "basic"
}
]
}
I wonder if it is possible to replace this with something similar to the code you quoted?
Or put in other words: What I want is to switch control and cmd, except for when using ctrl-(shift)-tab and alt-(shift)-tab (since I'm using the AltTab Program)
+1. And it also affects other events when you move the mouse at the same time when clicking the key combination that is subject to modifications.
I often move the mouse while switching tasks because I remember which corner of the screen the app is in, this is how I stumbled myself on this issue. Glad not to be alone :)
I made settings to make keys work similar to Ubuntu/Windows, including Alt+Tab without problem with mouse.
Place attached file to following location:
Users/[user]/.config/karabiner/assets/complex_modifications
Open "Karabiner - Simple Modifications"
Add modifications:
fn -> left_control
left_control -> fn
Open "Complex Modifications"
Add rules from "Normal keys" section as needed. Order of rules matters.
There is a special rule "CapsLock+DigitsLine to F1..F12", it is done for debugging. Digits work as F1..F12 when CapsLock is on. You need to switch off CapsLock if you want to write something during debugging, then switch it on back. It may get annoying, so you can remove this rule.
I made settings to make keys work similar to Ubuntu/Windows, including Alt+Tab without problem with mouse.
Place attached file to following location:
Users/[user]/.config/karabiner/assets/complex_modifications
Open "Karabiner - Simple Modifications"
Add modifications:
fn -> left_control left_control -> fn
Open "Complex Modifications"
Add rules from "Normal keys" section as needed. Order of rules matters.
There is a special rule "CapsLock+DigitsLine to F1..F12", it is done for debugging. Digits work as F1..F12 when CapsLock is on. You need to switch off CapsLock if you want to write something during debugging, then switch it on back. It may get annoying, so you can remove this rule.
Such a great response, finally working around this annoying mouse move issue! A big Thank You, @michael-vostrikov !
I made settings to make keys work similar to Ubuntu/Windows, including Alt+Tab without problem with mouse.
Place attached file to following location:
Users/[user]/.config/karabiner/assets/complex_modifications
Open "Karabiner - Simple Modifications"
Add modifications:
fn -> left_control left_control -> fn
Open "Complex Modifications"
Add rules from "Normal keys" section as needed. Order of rules matters.
There is a special rule "CapsLock+DigitsLine to F1..F12", it is done for debugging. Digits work as F1..F12 when CapsLock is on. You need to switch off CapsLock if you want to write something during debugging, then switch it on back. It may get annoying, so you can remove this rule.
Thanks! Do the screenshot shortcuts work though (cmd+shift+3, cmd+shift+4)? I think the rule "Cmd+All to Option+All" prevents them from working.
"cmd+shift+3, cmd+shift+4" become "fn+shift+3, fn+shift+4", they work. I see "cmd+ctrl+shift+3, cmd+ctrl+shift+4" do not work, I don't use them, so I did not notice. I think special rule for them in a separate file added before others should help.
I've modified the version from @d-allin abit, just to also disable the default cmd+tab, just in case someone is looking for it :D
{
"description": "Sticky Alt to Cmd Variable and Custom Ctrl+Tab => Cmd+Tab with Cmd+Tab Disabled",
"manipulators": [
{
"from": {
"key_code": "left_alt",
"modifiers": { "optional": ["any"] }
},
"to": [
{
"set_variable": {
"name": "left_alt pressed",
"value": 1
}
},
{ "key_code": "left_command" }
],
"to_after_key_up": {
"set_variable": {
"name": "left_alt pressed",
"value": 0
}
},
"type": "basic"
},
{
"conditions": [
{
"name": "left_alt pressed",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "tab",
"modifiers": {
"mandatory": ["command"],
"optional": ["any"]
}
},
"to": [
{
"key_code": "tab",
"modifiers": ["left_command"]
}
],
"type": "basic"
},
{
"description": "Disable default Cmd+Tab",
"from": {
"key_code": "tab",
"modifiers": {
"mandatory": ["command"],
"optional": ["any"]
}
},
"to": [{ "key_code": "vk_none" }],
"type": "basic"
}
]
}
I'm not sure how to describe this any better. I've created a rule like this:
It is to allow me to use ALT+TAB (mapped to OPTION+TAB) on my Windows (us-101) keyboard instead of CMD+TAB. It works fairly well, but if press ALT+TAB and move my mouse, it cancels the window switcher.
This same behavior happens for other multi-key combinations that involve holding down keys.