You could consider creating an actual flow that builds the logic, easier to debug;
2 examples (flow and function node):
example flow
[{"id":"a897ae3a.504908","type":"switch","z":"1735df89.7d022","name":"scene ?","property":"payload.event.label","propertyType":"msg","rules":[{"t":"eq","v":"Scene 003","vt":"str"},{"t":"eq","v":"Scene 004","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":396,"y":144,"wires":[["d11c944a.2030f"],[]]},{"id":"d11c944a.2030f","type":"switch","z":"1735df89.7d022","name":"Event Value ?","property":"payload.event.value","propertyType":"msg","rules":[{"t":"eq","v":"KeyPressed","vt":"str"},{"t":"eq","v":"KeyReleased","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":584,"y":120,"wires":[["68f64a94.0c8a84"],["e4a9b55a.dcab2"]]},{"id":"68f64a94.0c8a84","type":"change","z":"1735df89.7d022","name":"yay","rules":[{"t":"set","p":"payload.event.type","pt":"msg","to":"yay","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":96,"wires":[["f9d93252.3b527"]]},{"id":"e4a9b55a.dcab2","type":"change","z":"1735df89.7d022","name":"none","rules":[{"t":"set","p":"payload.event.type","pt":"msg","to":"none","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":144,"wires":[["f9d93252.3b527"]]},{"id":"f9d93252.3b527","type":"debug","z":"1735df89.7d022","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":962,"y":120,"wires":[]},{"id":"565e074d.a86eb","type":"function","z":"1735df89.7d022","name":"","func":"let event = msg.payload.event\n\nif (event.label == \"Scene 003\" && event.value == \"KeyPressed\"){\n msg.payload.event.type = \"yay\";\n}\nelse{\n msg.payload.event.type = \"none\";\n}\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":312,"wires":[["8a61f0d3.a2a8f"]]},{"id":"8a61f0d3.a2a8f","type":"debug","z":"1735df89.7d022","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":578,"y":312,"wires":[]},{"id":"3cb432b8.2698f6","type":"inject","z":"1735df89.7d022","name":"scene 003 - keypressed","props":[{"p":"payload.event.label","v":"Scene 003","vt":"str"},{"p":"payload.event.value","v":"KeyPressed","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":196,"y":120,"wires":[["a897ae3a.504908"]]},{"id":"a8430db1.fcbff","type":"inject","z":"1735df89.7d022","name":"scene 003 - keypressed","props":[{"p":"payload.event.label","v":"Scene 003","vt":"str"},{"p":"payload.event.value","v":"KeyPressed","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":196,"y":288,"wires":[["565e074d.a86eb"]]},{"id":"bb9e7a66.ec0098","type":"inject","z":"1735df89.7d022","name":"scene 003 - keyreleased","props":[{"p":"payload.event.label","v":"Scene 003","vt":"str"},{"p":"payload.event.value","v":"KeyReleased","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":206,"y":168,"wires":[["a897ae3a.504908"]]},{"id":"17fbfc81.c626d3","type":"inject","z":"1735df89.7d022","name":"scene 003 - keyreleased","props":[{"p":"payload.event.label","v":"Scene 003","vt":"str"},{"p":"payload.event.value","v":"KeyReleased","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":206,"y":336,"wires":[["565e074d.a86eb"]]}]