How do I temporarily prevent buttons to wake up screen?
Root the device;
Install Xposed framework;
Install Xposed Additions;
Enable Xposed Additions in Xposed Framework, restart the device;
Open Xposed Additions setup;
Buttons -> Allow External Devices -> Keyboard;
Add new Key -> Press the button you wan to disable on the keyboard -> OK -> Go to the newly appeared menu entry for the button you have chosen -> Add new Condition -> Screen Off -> Screen Off -> Click.


You will see "Click - Disabled" and the key won't work and won't wake up the device anymore.

You can also reassign it to some other key instead of disabling.