Add a hash key to your British mac keyboard

If you are using a British Apple keyboard and are writing CSS, to get a # character you need to press [option]+[3]. You may have noticed that the section key is not very useful, as it outputs the §, character, so you may want to remap the section key to output the # character instead.

Here is how you can do this:

  • Download and install Karabiner Elements from https://karabiner-elements.pqrs.org/
  • Launch Karabiner Elements and add a ‘simple modification’ to map ‘non_us_backslash’ to any key — eg the number 1.
  • edit the JSON file ~/.config/karabiner/karabiner.json in a text editor and locate the “simple_modification” block. Modify it to look like this:

    "simple_modifications": [
                    {
                        "from": {
                            "key_code": "non_us_backslash"
                        },
                        "to": {
                            "key_code": "3",
                            "modifiers": "option"
                        }
                    }
                ],
    

  • Your section key should now output the # character instead of the § character. This remapping will apply to all applications, so you can use the # symbol anywhere you need it.
  • Note that if you ever need to revert this change, you can simply remove the ‘simple modification’ in Karabiner Elements.