I don't map them to keystrokes at all, I have a (too specific to my needs to be open sourced) Python script that runs in the background, detects me pressing a MIDI note, and then does stuff. Think: a button for most frequent folders I need to open using VS Code, or lowering the volume (separate knobs for Firefox and Spotify), or a knob for dimming the lights in my living room / home office, things of that nature.
I built it using Mido (https://github.com/mido/mido), though there's so many other options for whichever language you prefer.