How to program my keyboard's numeric keypad?

[EDIT: Tidied things up a bit.]

I have an Apple Magic Keyboard with Numeric Keypad and KM does differentiate between the numpad keys and the others, so it is possible to remap them but it's not what I would call "pretty"!

Please note: I'm not saying this is a solution to your requirement but it might help you find the answer to your question.

So here goes...

First you need a macro to toggle the remapping. I've called it Numpad Mode Switch and it looks like this:

KM 1 2020-07-20_16-55-36

It basically sets a global variable to indicate whether the numpad keys are in remap mode or normal mode. I've set it to trigger when the Command-Enter keys are pressed. Here's the macro to download:

Numpad Mode Switch.kmmacros (4.9 KB)

Next comes the macro that actually does the remapping, and this is where it gets "not pretty". I've called the macro Numpad Remapping and here it is to download:

Numpad Remapping.kmmacros (25.8 KB)

(Both of these macros should be in you Global Macro Group, or equivalent.)

This macro is triggered by the numpad keys (I've included 0 to 9 and the decimal point as well). It works like this:

If the numpad is in normal mode, then the macro just repeats the key that's been pressed (the section of the macro in green).

If the numpad is in mapped mode (the section in teal), it replaces the pressed key with something else and executes it. In the macro itself, the mapping is performed by the actions coloured magenta; at present the macro just remaps the pressed key to a different one, but you can change these actions to any other actions (such as launching an app for example) as you wish - that's up to you.

I'm including an image of this macro at the end - just so others can see how it is constructed, but it is very long so I apologise in advance to posting something so unwieldy.

If you wanted to perform remapping depending on what app you are using, you could trigger the Numpad Mode Switch macro when that app comes to the front, but then you'd also have to reset the mode to normal once you leave that app. That's an exercise for you to work on!

I know you don't have an Apple keyboard, but you might be able to get some ideas from this post.

Good luck and let us know how you get on!

2 Likes