23

Is there any way to change the key mapping of the apple keyboard?

As programmer I find annoying there's a comma instead a dot in numeric keypad. I would remap this key to have dot ...

4
  • 1
    Possible duplicate of Decimal comma in Spanish keyboard layout Jul 6, 2017 at 18:37
  • Can you clarify which keyboard layout you are using?
    – Allan
    Jul 6, 2017 at 19:17
  • Italian kb layout
    – koalaok
    Jul 6, 2017 at 19:18
  • It's still relevant question in 2022. Replace dot to comma: { "#." = ("insertText:", ","); } or comma to dot: { "#," = ("insertText:", "."); }. Jun 14, 2022 at 19:23

6 Answers 6

37

The simplest solution is to create the file DefaultKeyBinding.dict in /Users/[user]/Library/KeyBindings if it does not already exist, and add the remapping:

{
   "#," = ("insertText:", ".");
}

Then logout or restart the mac.

The # indicates the remapping is for the keypad only. More reference for that file: https://gist.github.com/trusktr/1e5e516df4e8032cbc3d

7
  • 1
    Thanks ! I've been looking for something like this for few months. I didn't wanted to download a tool for this purpose....
    – ZazOufUmI
    Aug 6, 2018 at 6:28
  • 1
    This should be accepted as the answer, +1 for not needing another tool. By the way, a restart isn't necessary, just log out and log back in.
    – BoDeX
    Aug 21, 2019 at 2:16
  • 1
    This solution is working in Catalina (10.15 Beta) with no problems. Sep 19, 2019 at 2:23
  • Working on Catalina 10.15.2 Jan 27, 2020 at 13:38
  • 1
    Hi! I wanted to achieve the same result but in reverse, so dot to a comma. I placed this: { "#." = ("insertText:". ","); } in ~/Library/KeyBindings/DefaultKeyBinding.dict but it doesn't seem to work. I also tried with { "#," = ("insertText:". ","); } , but still not working... :(
    – panosru
    Oct 10, 2020 at 11:01
9

based on Matías González answer:

Step 1, Add the remapping (paste this command on your console):

mkdir ~/Library/KeyBindings && cd ~/Library/KeyBindings && touch DefaultKeyBinding.dict && echo '{"#," = ("insertText:", ".");}' > DefaultKeyBinding.dict

Step 2, Restart the mac

The # indicates the remapping is for the keypad only. More reference for that file: https://gist.github.com/trusktr/1e5e516df4e8032cbc3d

2
  • Would you get a comma again if you pressed shift this way? Because that would be desirable
    – Herman
    May 21, 2021 at 7:54
  • I don’t think so, but feel free to give it a try and comment your findings
    – Jose Paez
    May 21, 2021 at 13:59
5

If anyone is reading this in 2022 and using Mac OS X 12.1 (Monterey) and wants to change dot (.) to comma (,) on a number keypad, try the following steps:

  1. Open the Terminal application;
  2. Paste this code on it:
hidutil property --set '
{"UserKeyMapping": [
    {
        "HIDKeyboardModifierMappingSrc": 0x700000063,
        "HIDKeyboardModifierMappingDst": 0x700000036
    },
]}'
  1. Press enter;
  2. Enjoy it!

0x700000063 means dot char .

0x700000036 means comma char ,


Reference: https://developer.apple.com/library/archive/technotes/tn2450/_index.html

2
  • Excellent, thanks for the update. Since I use a different keyboard layout (bépo), thanks to the table you have referenced, I managed to figure out that I needed to replace 0x700000063 by 0x700000019. Now it works as expected 🥳 It prints a v when I change the keyboard back to French, but that's no big deal for me.
    – Arnaud P
    Sep 3, 2021 at 6:17
  • 2
    BTW if anyone wants to cancel their changes after experimenting with this: apple.stackexchange.com/a/374073
    – Arnaud P
    Sep 3, 2021 at 6:19
2

I changed my keyboard from "Dutch" to "US international - PC" and my numpad dot works as expected. It's no longer giving me a comma.

1
  • 1
    So easy and exactly what fixes the problem in a sensible way! After all, I am using a International board.... It makes total sense!
    – RemyNL
    Oct 12, 2022 at 8:48
1

One solution is Karabiner (prior to version 9.3.0, Karabiner was called KeyRemap4MacBook). It allows you to remap specific keys or change then entire keyboard layout, as described here.

It is a powerful keyboard remapper that can change not only the functionality of keys and key combinations, but just about everything related to how a key repeats when you hold it down. Keyboard remappings are highly customizable (although it's not a so simple process). You can change practically anything: you can search through all the options and quickly find what you're looking for, or just browse by category. It's very powerful and usage is pretty straightforward.

The drawback is that keyboard remapping functions are predefined and you can just check them off. If you want to add custom remapping functions, you have to edit an XML file. When you're using a GUI application this is not exactly the ideal experience. That said, this is the only significant drawback.

1
  • Thanks for this one... I'm starting to do my taxes for 2017 and it was really bugging the crap out of me in excel! Dec 30, 2017 at 18:04
1

For the reverse that Panosru is looking for I believe that the correct syntax within ~/Library/KeyBindings/DefaultKeyBinding.dict should be:

{
   "#." = ("insertText:". ",");
}

As the comma after "insertText" is a separator between the command and the wanted character.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .