Hi all and thank you so much for this great tool...
is it possible to use arrows as modifier keys, in either simple or complex modifications?
In order to be able to move diagonally in some old DOS games, I would like to achieve something like this:
Rule 1: from ("up" + "left_arrow") to ("home")
Rule 2: from ("up" + "right_arrow") to ("page_up")
Rule 3: from ("down" + "left_arrow") to ("end")
Rule 4: from ("down" + "right_arrow") to ("page_down")
Made a first attempt, so fare it seems that the first three rules work perfectly, but not rule 4 but it has exactly the same structure as the other three rules, why is it not working?
{
"title": "Diagonals",
"rules": [
{
"description": "Diagonals",
"manipulators": [
{
"from": {
"key_code": "left_arrow"
},
"to": [
{
"set_variable": {
"name": "left_modifier",
"value": 1
}
},
{
"key_code": "left_arrow"
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "left_modifier",
"value": 0
}
}
],
"to_if_alone": [
{
"key_code": "left_arrow"
}
],
"type": "basic"
},
{
"from": {
"key_code": "right_arrow"
},
"to": [
{
"set_variable": {
"name": "right_modifier",
"value": 1
}
},
{
"key_code": "right_arrow"
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "right_modifier",
"value": 0
}
}
],
"to_if_alone": [
{
"key_code": "right_arrow"
}
],
"type": "basic"
},
{
"conditions": [
{
"type": "variable_if",
"name": "left_modifier",
"value": 1
}
],
"from": {
"key_code": "up_arrow"
},
"to": [
{
"key_code": "home"
}
],
"type": "basic"
},
{
"conditions": [
{
"type": "variable_if",
"name": "left_modifier",
"value": 1
}
],
"from": {
"key_code": "down_arrow"
},
"to": [
{
"key_code": "end"
}
],
"type": "basic"
},
{
"conditions": [
{
"type": "variable_if",
"name": "right_modifier",
"value": 1
}
],
"from": {
"key_code": "up_arrow"
},
"to": [
{
"key_code": "page_up"
}
],
"type": "basic"
},
{
"conditions": [
{
"type": "variable_if",
"name": "right_modifier",
"value": 1
}
],
"from": {
"key_code": "down_arrow"
},
"to": [
{
"key_code": "page_down"
}
],
"type": "basic"
}
]
}
]
}
Maybe simultaneous can help you?
This works for me, though the "simultaneous" effect may not be what you want:
{
"description": "Arrow stuff",
"manipulators": [
{
"type": "basic",
"from": {
"simultaneous": [
{
"key_code": "up_arrow"
},
{
"key_code": "left_arrow"
}
],
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "home"
}
]
}
]
}
Also, note that the default shortcuts on Mac translate:
In case that can be helpful
Many thanks @thoelze1 , I tried your attempt and it may work much better than mine (in mine rule number 4 does not work, perhaps because of some bug, in yours even rule number 4 works!)
But there is an issue, sometimes I may want to press, for example the up arrow _while_ I was already pressing the left arrow (or viceversa)... that is, instead of pressing both buttons _at the same time_ I would like the rule to be triggered also when I press one of the two buttons, and after a while I also press the other button...
In this case, it seems that the simultaneous rule is not triggered... I tried to increase the "simultaneous threshold" from 50ms to bigger values, like 10000ms (ten seconds), but if I do this and I press just one of the two buttons, it seems that it waits for 10 seconds to see if I will also press the second button... what do you think?
And thanks for your suggetion about the fn key, perhaps I may also try think about some simpler rules which involve translating that key into something else, although that is not easy...
I am realizing that perhaps the event_changed_if may halp to solve the issue above, but I have only seen a single sentence about its meaning in the documentation and no examples online or anywhere on internet, and I am not managing to understand how to use it...
I tried your code, and it worked for me. Specifically, when I held left_arrow, then up_arrow became home and down_arrow became end; when I held right_arrow, then up_arrow became page_up and down_arrow became page_down.
However, if I held up_arrow, then left_arrow still acted as left_arrow (instead of home, which it sounds like you want it to). So I added rules that make up_arrow and down_arrow set variables up_modifier and down_modifier, and I added rules so that when each arrow is pressed, it checks if another arrow is currently being held down, and then remaps according to the 4 rules you originally posted in this issue. Here's the code:
{
"title": "Diagonals",
"rules": [
{
"description": "Diagonals",
"manipulators": [
{
"conditions": [
{
"type": "variable_if",
"name": "up_modifier",
"value": 1
}
],
"from": {
"key_code": "left_arrow"
},
"to": [
{
"set_variable": {
"name": "left_modifier",
"value": 1
}
},
{
"key_code": "home"
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "left_modifier",
"value": 0
}
}
],
"type": "basic"
},
{
"conditions": [
{
"type": "variable_if",
"name": "down_modifier",
"value": 1
}
],
"from": {
"key_code": "left_arrow"
},
"to": [
{
"set_variable": {
"name": "left_modifier",
"value": 1
}
},
{
"key_code": "end"
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "left_modifier",
"value": 0
}
}
],
"type": "basic"
},
{
"from": {
"key_code": "left_arrow"
},
"to": [
{
"set_variable": {
"name": "left_modifier",
"value": 1
}
},
{
"key_code": "left_arrow"
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "left_modifier",
"value": 0
}
}
],
"type": "basic"
},
{
"conditions": [
{
"type": "variable_if",
"name": "up_modifier",
"value": 1
}
],
"from": {
"key_code": "right_arrow"
},
"to": [
{
"set_variable": {
"name": "right_modifier",
"value": 1
}
},
{
"key_code": "page_up"
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "right_modifier",
"value": 0
}
}
],
"type": "basic"
},
{
"conditions": [
{
"type": "variable_if",
"name": "down_modifier",
"value": 1
}
],
"from": {
"key_code": "right_arrow"
},
"to": [
{
"set_variable": {
"name": "right_modifier",
"value": 1
}
},
{
"key_code": "page_down"
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "right_modifier",
"value": 0
}
}
],
"type": "basic"
},
{
"from": {
"key_code": "right_arrow"
},
"to": [
{
"set_variable": {
"name": "right_modifier",
"value": 1
}
},
{
"key_code": "right_arrow"
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "right_modifier",
"value": 0
}
}
],
"type": "basic"
},
{
"conditions": [
{
"type": "variable_if",
"name": "left_modifier",
"value": 1
}
],
"from": {
"key_code": "up_arrow"
},
"to": [
{
"set_variable": {
"name": "up_modifier",
"value": 1
}
},
{
"key_code": "home"
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "up_modifier",
"value": 0
}
}
],
"type": "basic"
},
{
"conditions": [
{
"type": "variable_if",
"name": "left_modifier",
"value": 1
}
],
"from": {
"key_code": "down_arrow"
},
"to": [
{
"set_variable": {
"name": "down_modifier",
"value": 1
}
},
{
"key_code": "end"
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "down_modifier",
"value": 0
}
}
],
"type": "basic"
},
{
"conditions": [
{
"type": "variable_if",
"name": "right_modifier",
"value": 1
}
],
"from": {
"key_code": "up_arrow"
},
"to": [
{
"set_variable": {
"name": "up_modifier",
"value": 1
}
},
{
"key_code": "page_up"
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "up_modifier",
"value": 0
}
}
],
"type": "basic"
},
{
"conditions": [
{
"type": "variable_if",
"name": "right_modifier",
"value": 1
}
],
"from": {
"key_code": "down_arrow"
},
"to": [
{
"set_variable": {
"name": "down_modifier",
"value": 1
}
},
{
"key_code": "page_down"
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "down_modifier",
"value": 0
}
}
],
"type": "basic"
},
{
"from": {
"key_code": "up_arrow"
},
"to": [
{
"set_variable": {
"name": "up_modifier",
"value": 1
}
},
{
"key_code": "up_arrow"
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "up_modifier",
"value": 0
}
}
],
"type": "basic"
},
{
"from": {
"key_code": "down_arrow"
},
"to": [
{
"set_variable": {
"name": "down_modifier",
"value": 1
}
},
{
"key_code": "down_arrow"
}
],
"to_after_key_up": [
{
"set_variable": {
"name": "down_modifier",
"value": 0
}
}
],
"type": "basic"
}
]
}
]
}
Hope this helps!
Hi @thoelze1 and thank you so much for this... it seems it works much better, but there is still a problem... if, for example, I press the left arrow, and afterwards at some point I also press the up arrow, then it correctly goes diagonally, because the left arrow acted as a sort of "modifier" as expected... and if, after that, I release the up arrow, then it goes left again, as expected...
But, if instead of releasing the up arrow, I release the left arrow instead, I would expect it to go up, since only the up arrow is being held down... but instead it keeps going diagonally...
I am starting to think that the software does not support yet this kind of modification, what do you think? It is a pity, because many games already have this feature natively, and being able to do this via karabiner would make us capable of doing this with all games, not only the ones which have this feature natively...
I hope that karabiner supports this somehow, because I have been trying to get similar behavior for a modification of my own. Perhaps if we could figure out what event_changed_if does, it could be of some help; however, I opened up an issue asking about event_changed_if and I spent a while experimenting but I haven't been able to figure it out.
Thank you so much for this @thoelze1 , I have found the issue and I will follow it, let's hope we will manage to make this work :)
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.