Skip to content

bluetooth – How can I configure a key to “Start Dictation” with a Microsoft Surface Ergonomic Keyboard?

  • by
Spread the love


I finally figured out a decent solution with Karabiner-Elements. I just found out that it supports complex rules with variables, conditions, and delays, so I was able to customize the behavior of the Enter key on my keypad. I set up a rule that will start dictation if I press it twice, but I can still use the Enter key if I only press it once (with a short delay.)

Here is my JSON rule:

{
  "title": "Double tap keypad_enter to double tap fn (start dictation.) Single tap for keypad_enter after a short delay (250ms.)",
  "rules": [
    {
      "description": "This rule solves a problem with the Microsoft Surface Ergonomic Keyboard. The `Fn` key can't be used to start dictation, since it only toggles an internal state on and off, and it does not actually send any keypress event. This rule allows you to start dictation by double tapping the keypad enter key, which will send Fn twice. If you only press the keypad enter key once, it will send the original enter key after a short delay (250ms).",
      "manipulators": [
        {
          "conditions": [
            {
              "name": "keypad_enter pressed",
              "type": "variable_if",
              "value": 1
            }
          ],
          "from": {
            "key_code": "keypad_enter",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "fn"
            }
          ],
          "type": "basic"
        },
        {
          "from": {
            "key_code": "keypad_enter",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "set_variable": {
                "name": "keypad_enter pressed",
                "value": 1
              }
            },
            {
              "key_code": "fn"
            }
          ],
          "parameters": {
            "basic.to_delayed_action_delay_milliseconds": 250
          },
          "to_delayed_action": {
            "to_if_canceled": [
              {
                "set_variable": {
                  "name": "keypad_enter pressed",
                  "value": 0
                }
              }
            ],
            "to_if_invoked": [
              {
                "set_variable": {
                  "name": "keypad_enter pressed",
                  "value": 0
                }
              },
              {
                "key_code": "keypad_enter"
              }
            ]
          },
          "type": "basic"
        }
      ]
    }
  ]
}

I have also submitted a PR to add this example to their documentation.

If this PR is merged then you will be able to visit https://ke-complex-modifications.pqrs.org and click the blue “Import” button to import the JSON into your Karabiner-Elements app.

In the meantime, here is how you can manually import the rule.

Open a new file in your text editor, and paste the JSON above. Save the file to your home directory: ~/double_tap_keypad_enter_to_double_tap_fn.json

Open a terminal and run these commands:

mkdir -p ~/.config/karabiner/assets/complex_modifications/
mv ~/double_tap_keypad_enter_to_double_tap_fn.json ~/.config/karabiner/assets/complex_modifications/

(The ~/.config directory is usually hidden from Finder and the “Save File” window, so it’s easier to use the terminal for this step.)

Go to the Complex Modifications page and click Add Rule. (You don’t need to restart Karabiner-Elements if it’s already running, it should find the new JSON file immediately.)

Complex Modifications => Add Rule

You should see the new rule. Click “Enable”.

Enable the new rule

Finally, make sure your keyboard settings are correct. (In case you’ve been trying a few other things before finding this solution.)

Open the System Preferences and click “Keyboard”.

Make sure the dictation shortcut is configured correctly: “Press ๐ŸŒ to Start Dictation (Press ๐ŸŒ twice)”

dictation shortcut

Side note: The Microsoft Surface Ergonomic Keyboard doesn’t actually have a ๐ŸŒ Globe key, but this is just the Fn key with a different name and icon.

Now click “Modifier Keys”:

keyboard modifier keys button

You should see the virtual Karabiner keyboard driver, and the Globe (๐ŸŒ) key should be set to ๐ŸŒ Globe.

keyboard settings modifier keys

The rule is now active, so open your text editor and try it out. When you press the keypad enter key once, you should see a new line after a short delay. When you press it twice, it should start dictation.

Please feel free to modify this rule and choose your own key, or change all of the logic. I hope this example can help you get started with your own customizations. Make sure you check out some of the other examples in the documentation, and read the “complex modification” documentation to see all the things you can do with Karabiner-Elements.

Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *