This isn’t remapping of a key on the keyboard but rather assigning a *macro* to a key.

As a project, I attached a second (Logitech) keyboard to my Mac to act as a makeshift “board” of sorts that autmated several actions.  One of these was issuing commands in Think-or-Swim (TD Ameritrade) for pulling up charts and entering orders.

There are two tools you can use.  Both are paid apps, but they each have trial periods (ControllerMate is unlimited, but limits the number of actions)

* ControllerMate.  See [this answer][1] for more details.
* [USB Overdrive][2].  
* [Keyboard Maestro][3]. 

In my experimentation, I was able to program buttons on the second keyboard to launch new instances of Firefox with a specific profile, issue several key presses in a certain sequence (ToS), and even run AppleScripts.  It’s not required to have a second keyboard (you can remap any key on your existing keyboard), I was trying to emulate products like the [X-Keys][4] products.

I attempted to do this with AppleScript, but it tended to break when the software was updated.  I found both ControllerMate and USB Overdrive to meet the requirements perfectly. I’ve not used Keyboard Maestro.

Currently, I have a 10-key USB keypad that I assigned macros  in Lightroom to automate repetitive tasks.  I abandoned the ToS project because I’m not a trader.  20-30 trades a month was too little for the effort required to maintain this.  


  [1]: https://apple.stackexchange.com/a/287612/119271
  [2]: http://www.usboverdrive.com/USBOverdrive/News.html
  [3]: https://www.keyboardmaestro.com/main/
  [4]: https://xkeys.com/