This mode is entered by pressing Fn + M (mouse) on my HHKB. (Behind the scenes, I remapped Fn + M to F16 for this purpose.) You exit the mode by pressing Fn + N (navigation) right beside it. (Mapped to F18 internally, for Karabiner to catch it.) I didn't use a toggle this time because leaving the HHKB in Mouse mode is too disruptive. I want to be able to jam it directly in and out this mode without needing to think about it. So dedicated Mouse and Navigation Fn keys it is.
This file contains two different mousing rules, which are individually selectable in Karabiner’s complex modifications tab. One is for my beloved sixty percent boards, bringing them “HHKB-style” mouse keys on the familiar cursor keys. The other is for full-size keyboards, whose numpads are crying out for a good use.
Code: Select all
{
"title": "🖱 Mouse Key Modes",
"rules": [
{
"description": "🖱 Numpad Mouse Keys",
"manipulators": [
{
"from": {
"key_code": "keypad_num_lock",
"modifiers": {
"optional": [
"caps_lock"
]
}
},
"type": "basic",
"to": [
{
"set_variable": {
"name": "numpad_mode",
"value": 1
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
},
{
"from": {
"key_code": "keypad_num_lock",
"modifiers": {
"optional": [
"caps_lock"
]
}
},
"type": "basic",
"to": [
{
"set_variable": {
"name": "numpad_mode",
"value": 0
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 1
}
]
},
{
"from": {
"key_code": "n",
"modifiers": {
"mandatory": [
"fn"
],
"optional": [
"caps_lock"
]
}
},
"type": "basic",
"to": [
{
"set_variable": {
"name": "numpad_mode",
"value": 1
}
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_1",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"mouse_key": {
"x": -1500,
"y": 1500
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_2",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"mouse_key": {
"y": 2121
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_3",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"mouse_key": {
"x": 1500,
"y": 1500
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_4",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"mouse_key": {
"x": -2121
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_5",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"mouse_key": {
"y": 1000
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_6",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"mouse_key": {
"x": 2121
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_7",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"mouse_key": {
"x": -1500,
"y": -1500
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_8",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"mouse_key": {
"y": -2121
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_9",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"mouse_key": {
"x": 1500,
"y": -1500
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_hyphen",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"mouse_key": {
"vertical_wheel": -48
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_plus",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"mouse_key": {
"vertical_wheel": 48
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_0",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"pointing_button": "button1"
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_period",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"pointing_button": "button2"
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_slash",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"mouse_key": {
"horizontal_wheel": 48
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_asterisk",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"mouse_key": {
"horizontal_wheel": -48
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "numpad_mode",
"value": 0
}
]
}
]
},
{
"description": "🖱 HHKB Style Mouse Keys",
"manipulators": [
{
"from": {
"key_code": "f16",
"modifiers": {
"optional": [
"caps_lock"
]
}
},
"type": "basic",
"to": [
{
"set_variable": {
"name": "mouse_keys_mode",
"value": 1
}
}
]
},
{
"from": {
"key_code": "f18",
"modifiers": {
"optional": [
"caps_lock"
]
}
},
"type": "basic",
"to": [
{
"set_variable": {
"name": "mouse_keys_mode",
"value": 0
}
}
]
},
{
"from": {
"key_code": "n",
"modifiers": {
"mandatory": [
"fn"
],
"optional": [
"caps_lock"
]
}
},
"type": "basic",
"to": [
{
"set_variable": {
"name": "mouse_keys_mode",
"value": 0
}
}
]
},
{
"type": "basic",
"from": {
"key_code": "left_arrow"
},
"to": [
{
"mouse_key": {
"x": -3000
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "mouse_keys_mode",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "right_arrow"
},
"to": [
{
"mouse_key": {
"x": 3000
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "mouse_keys_mode",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "up_arrow"
},
"to": [
{
"mouse_key": {
"y": -3000
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "mouse_keys_mode",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "down_arrow"
},
"to": [
{
"mouse_key": {
"y": 3000
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "mouse_keys_mode",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "page_up"
},
"to": [
{
"mouse_key": {
"vertical_wheel": -48
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "mouse_keys_mode",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "page_down"
},
"to": [
{
"mouse_key": {
"vertical_wheel": 48
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "mouse_keys_mode",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "pause"
},
"to": [
{
"pointing_button": "button1"
}
],
"conditions": [
{
"type": "variable_if",
"name": "mouse_keys_mode",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "delete_forward"
},
"to": [
{
"pointing_button": "button1"
}
],
"conditions": [
{
"type": "variable_if",
"name": "mouse_keys_mode",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "f17"
},
"to": [
{
"pointing_button": "button2"
}
],
"conditions": [
{
"type": "variable_if",
"name": "mouse_keys_mode",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "keypad_slash",
"modifiers": {"optional": ["any"]}
},
"to": [
{
"mouse_key": {
"horizontal_wheel": 48
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "mouse_keys_mode",
"value": 1
}
]
},
{
"type": "basic",
"from": {
"key_code": "home"
},
"to": [
{
"mouse_key": {
"horizontal_wheel": -48
}
}
],
"conditions": [
{
"type": "variable_if",
"name": "mouse_keys_mode",
"value": 1
}
]
}
]
}
]
}
Points if you can figure out why some numpad keys move the mouse pointer 1500 × 1500 units while others move it 2121. Hint: love having true diagonals. Especially chording them with cardinal arrows to get the full complement of 16 directions like NNE and WSW. Feels immediately obvious when you have that “joystick” right there.