This works fine and short press turns off the screen and long press brings up the power menu.
The next step was to disable the short press and I did this by changing config_shortPressOnPowerBehavior to 0 (Nothing). I also don't want the menu but just to turn off the device so I also changed config_longPressOnPowerBehavior to 3 (Power off (without confirmation)). Both settings were in frameworks/base/core/res/res/values/config.xml.
The problem I'm having is turning off the device using power menu only turns off the SOM and Android, the board stays on. Also changing both or any of these button settings makes the button non-functional.
Does anyone have an idea of why this might be happening?