You can do this with Keyboard Maestro's Device Key trigger:
Device Key
The macro can be executed when the key is pressed, released or periodically while it is held down. The trigger can also optionally be restricted to when certain modifier keys are pressed.
Device Key triggers can be combined with a macro group restricting to a certain application.