Hello,
I have used a HIDmacros, from hidmacros.eu to do exactly what you are trying to do in FSX, but I do not see why it wouldn't work in P3D. It recognises different keyboards and allows you to assign functions to it. I have a numeric keyboard for view control and a second keyboard for more complex functions that integrate with FSUIPC.
HIDmacros is no longer supported by the developer, but is open source and works fine on Windows 7, I cannot vouch for Windows 10. It can be a little quirky to set up, and can lose setting if started without the keyboard attached. I keep a backup of the settings file in case this happens.