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 a few tools you can use. All are paid apps, but they each have trial periods (ControllerMate is unlimited, but limits the number of actions)
- ControllerMate. See this answer for more details.
- USB Overdrive.
- Keyboard Maestro.
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 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.