Is there anyway to set double tap shift to toggle caps lock?
(Currently, I've a remap of my caps lock to esc, but rarely I miss the ability to toggle caps mode)
Hi @tekezo, I looked at the issue you referenced but can't find anything about implementing double-tap. I'd like to map double-tap left shift to ESC.
So how do we do double tap on a key? #369 doesn't exactly say.
You can accomplish this by using variables. The docs has an example. It works well for me.
I figure it out by this , double tap left shift to switch cap_lock
{
"description": "double left shift to cap_lock",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_shift",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "caps_lock"
}
],
"conditions": [
{
"type": "variable_if",
"name": "left_shift pressed",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "left_shift",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"set_variable": {
"name": "left_shift pressed",
"value": 1
}
},
{
"key_code": "left_shift"
}
],
"to_delayed_action": {
"to_if_invoked": [
{
"set_variable": {
"name": "left_shift pressed",
"value": 0
}
}
],
"to_if_canceled": [
{
"set_variable": {
"name": "left_shift pressed",
"value": 0
}
}
]
}
}
]
}
I figure it out by this , double tap left shift to switch cap_lock
{ ... }
Just in case anyone reads this and wants to change the time in which you need to press shift the second time, you can add the basic.to_delayed_action_delay_milliseconds parameter
@ZhengkunWang Any idea why caps lock will turn on but not off if "modifiers": {"optional": ["any"]} is missing?
@ZhengkunWang Any idea why caps lock will turn on but not off if
"modifiers": {"optional": ["any"]}is missing?
Caps lock is a modifier key, along with Fn, Control, Alt, Shift, Option and Command. So if you want use a modification even when caps lock is enabled, you will have to explicitly mention caps_lock or any in modifiers.optional. Else, it won't trigger. any means you can use it with any modifier keys. And, if you want a modification to work only when caps lock is enabled, add caps_lock in modifiers.mandatory. The same goes for other modifier keys. See below link for more information.
Tip
If you do not include
anyinmodifiers.optional, your manipulator does not change event if extra modifiers (modifiers which are not included inmodifiers.mandatory) are pressed.
Most helpful comment
I figure it out by this , double tap left shift to switch cap_lock