Karabiner should be able to do that for you.
If this is a USB device, you might be able to do use Keyboard Maestro too.