Karabiner is an epic keyboard mapping tool for MacOS. I haven't found a tool I have liked as much on Linux but I hear there is a tool on Windows that is pretty good.
Karabiner allows for lots of configuration - sim-layers, layers, keys that perform different functions when held or when tapped or when used in connection with others.
Configuring it requires handling a large JSON object. I use Goku to write my configuration.
I've included a snapshot here.
The most useful thing I have it o-k which Opens Karabiner configuration. I'm flipping back to my configuration all day to update this and add new things.
Useful resources
John Linquist's talk Goku Karabiner